Installing Paste, WSGI Utilities and Flask
Pretty straightforward:
apt-get update
apt-get install python-pastescript -y
apt-get install python-pip -y
pip install wsgiutils
pip install flask
Creating a wsgi.py file to expose the application
The wsgi.py just contains a factory function that returns an instance of Flask's wsgi_app. The code assumes that your Flask application is called "app" and the file that contains it your_app_package.py:from your_app_package import app
def app_factory(global_config, **local_config):
return app.wsgi_app
Creating a config file for Paster
Create a config.ini file like this:
[app:main]
paste.app_factory = wsgi:app_factory
[server:main]
use = egg:PasteScript#wsgiutils
host = 123.45.67.8
port = 80
Make sure to replace the host property with the IP address of your server.
Running Paster
Add the current directory to the python path and pass the config file to `paster serve`:
Now your website should be served and at least accessible locally. Try `curl localhost` to confirm.
export PYTHONPATH=.
paster serve ./config.ini
Now your website should be served and at least accessible locally. Try `curl localhost` to confirm.