$ sudo apt-get install python3-venv
# clone the repository
$ cd /home
$ git clone https://github.com/geobretagne/mreport.git
$ cd mreport
Create a virtualenv and activate it
$ python3 -m venv venv
$ . venv/bin/activate
Install Flask and dependencies
$ pip install -r requirements.txt
Edit config.py and set
- SQLALCHEMY_DATABASE_URI
Another default config params are :
- API_LOCATION = '/api'
- APP_SCHEME = 'http'
- MREPORT_REPORTS = "backend/reports"
- MREPORT_LOCATION = "/mreport"
- ADMIN_LOCATION = "/admin"
$ export FLASK_APP=frontend
$ flask run
test http://localhost:5000/mreport/sample/ECLUSE_1
test http://localhost:5000/admin/
$ export FLASK_APP=backend
$ flask run
test http://localhost:5000/api
$ python3 dispatcher.py
test http://localhost:5000/api
test http://localhost:5000/admin/
test http://localhost:5000/mreport/sample/ECLUSE_1
$ gunicorn -b 0.0.0.0:5000 dispatcher
Create a .service file for the api. (/etc/systemd/system/mreport.service):
[Unit]
Description=mreport
After=network.target
[Service]
User=mreport
Restart=on-failure
WorkingDirectory=/tmp/
ExecStart=/home/mreport/mreport/venv/bin/gunicorn -b 0.0.0.0:5000 dispatcher
[Install]
WantedBy=multi-user.target
Enable and start the service
$ sudo systemctl daemon-reload
$ sudo systemctl enable mreport
$ systemctl start mreport