Hello World again. This is my second post and I'm going to write about the steps it took me to get my Flask Application deployed to a Webserver.
Content of this Tutorial
- Part 1: Choosing the right webservice provider
- Part 2: Flask Development Server
- Part 3: Gunicorn WSGI Application Webserver
- Part 4: Nginx Proxy Server
Finding the right Hosting Service
Of course when developing your web application there will be the time when you want to unleash it to the world. That means you need some kind of Webserver where you can deploy your application. There exist a huge amount of hosting services in the web. Apart from the classic (virtual) Linux server there are the so called Platforms as a Service (e.g. Heroku). A Platform as a Service allows you to deploy your app without worrying about the operating system and server configuration. You just write your application plus a small config file and upload it to the platform (e.g by pushing your git repository to the server). However you have to pay for this convenience. In fact Heroku provides a free account for experimenting but the app will got to sleep for at least 6 hours a day. For small scale projects without downtime you will have to pay 7$ a month.
The cheaper but more sophisticated solution is to use a virtual Linux server and configure it the way that it serves your Flask application. Eventually one has to decide whether to save time or money. In my case I wanted to keep the monthly costs for my Blog low. Also I was curious about how to get my own Webserver running from scratch. So I will continue by describing how I got my Server working.
Requirements
If you want to serve a Flask application your webserver will have to provide at least the following features:
- some kind of remote control, e.g. SSH
- root privileges to install Python and Python packages your application depends on
- depending on the kind of application you also need a Database server (mysql, mariadb)
If you want your new application to be accessible by a Domain name and not only by the IP address of the server you will also need to acquire a domain name.
Setting up the Server
Let's get to work. In my next post I will describe how to set up a Linux Server with Debian "Jessie" installed on it in a way that it can be used to serve a Flask application. We will build a Flask Test Application and serve it with the builtin development server.