Posts

Showing posts with the label python

[Python] How to Serve Flask Application with uWSGI and Nginx

As python Flask library has a built-in web server, there shouldn't be a problem to serve a web application by just executing the python script while developing or testing. However, when we are deploying an app for real service, it is better to use a web server such as Nginx and Apache considering the performance on live servers. In addition, we use uWSGI to use the web server. To be specific, if uWSGI executes the python application locally and Nginx communicates with the external users, uWSGI communicates with Nginx to serve the python app. Following are the steps to integrate uWSGI with Nginx 1. Install nginx and python uwsgi plugin sudo apt-get install nginx sudo apt-get install uwsgi-plugin-python 2. Install python library uwsgi. sudo pip install uwsgi 3. Open uwsgi.ini and save the configuration. sudo nano /etc/uwsgi/apps-enabled/uwsgi.ini [uwsgi] chdir=/home/hama/project uid=root gid=root virtualenv=/home/hama/project/venv chmod-socket= 666 callable