Skip to content

Flask API

Giovanni Garifo edited this page Nov 5, 2019 · 1 revision

Flask API

First deployment

guide

  1. clone git repository inside /var/www/, it's required to add credentials to the config.py file
  2. install WSGI mod for apache2 sudo apt-get install libapache2-mod-wsgi python-dev
  3. enable the installed mod with a2enmod modname
  4. Install pip python pkg manager: sudo apt-get install python3-pip
  5. install python pkgs required: pip3 install Flask; pip3 install requests;
  6. test if the app works: python3 app.py
  7. configure apache2 virtual host geranium-api.conf like this:
<VirtualHost *:80>
                ServerName api.geranium.org
                ServerAdmin admin@localhost
                WSGIScriptAlias / /var/www/geranium/process/geranium-api.wsgi
                <Directory /home/geranium/geranium/process/>
                        Require all granted
                </Directory>
                Alias /static /var/www/geranium/process/static
                <Directory /var/www/geranium/process/static/>
                        Require all granted
                </Directory>
                ErrorLog ${APACHE_LOG_DIR}/error.log
                LogLevel warn
                CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
  1. add to geranium-api.wsgi
root@geranium:/var/www/geranium/process# cat geranium-api.wsgi 
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/geranium/process/")

from app import app as application
application.secret_key = b'biek9Va2aechie3Ljoh1Aisi'

Deployment of new version

  • git pull the new version
  • add credentials to config.py

Clone this wiki locally