Flask is a microframework for Python based on Werkzeug, Jinja 2 and good intentions. And before you ask: It's BSD licensed!I came across Flask when I was going through the apps from Hasgeek. All their sites are built on Flask. So I thought of giving it a try and I'm not disappointed. Flask is awesome. Minimal, supports Jinja for template managing and all you have to do is work on your app logic. Very less work involved to manage the framework. Here are the quick steps to follow to develop with Flask and deploy the app on an Nginx server -
- Install Flask in a vertualenv.
- Make a file named your_app_name.py and start building your app.
- Test the app locally and when you think you're ready to deploy prepare your server.
- Install gcc, python, python-dev, python-virtualenv on your server.
- many deployment options, I chose uWSGI. It seemed to have very little footsteps.
- Setup the virtualenv and transfer your files to server.
- Install uWSGI inside your virtualenv with pip.
pip install uwsgi
- Deploy using uWSGI and Supervisor. Just one thing, instead of using that Symlink method to deploy your site, you might prefer to use these nginx_ensite and nginx_dissite commands.
- I made a special executable named nginx_renabsitethat disables the provided site config, reloads the server, then enables new config and again reloads the server -
nginx_dissite $1 /etc/init.d/nginx reload nginx_ensite $1 /etc/init.d/nginx reloadPlace this file to /usr/sbin/nginx_renabsiteand you can run it like
$ nginx_renabsite site_config_filename
- Your app should be up and running by now.
- Once you make any changes to your app, upload the files to server, then reload Supervisor with supervisorctl.