Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
spelhate committed Jun 9, 2020
1 parent 1d86372 commit f9b5dca
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 21 deletions.
36 changes: 23 additions & 13 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Prerequis
----------

$ sudo apt-get install python3-venv


Install
---------

Expand All @@ -28,7 +28,18 @@ Install Flask and dependencies
Configure
---------

Edit config.py and set SQLALCHEMY_DATABASE_URI
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"




Expand All @@ -37,37 +48,37 @@ Test frontend

$ export FLASK_APP=frontend
$ flask run

test http://localhost:5000/mreport/sample/ECLUSE_1

test http://localhost:5000/admin/

Test backend
--------------

$ export FLASK_APP=backend
$ flask run

test http://localhost:5000/api





Tester frontend & backend
--------------------------

$ python3 dispatcher.py

test http://localhost:5000/api
test http://localhost:5000/admin/
test http://localhost:5000/mreport/sample/ECLUSE_1


gunicorn
--------


$ gunicorn -b 0.0.0.0:5000 dispatcher

```Create a .service file for the api. (/etc/systemd/system/mreport.service):```

```
Expand All @@ -91,4 +102,3 @@ WantedBy=multi-user.target
$ sudo systemctl daemon-reload
$ sudo systemctl enable mreport
$ systemctl start mreport

2 changes: 1 addition & 1 deletion backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def __repr__(self):



app.wsgi_app = CherrokeeFix(app.wsgi_app, app.config['APP_PREFIX'], app.config['APP_SCHEME'])
app.wsgi_app = CherrokeeFix(app.wsgi_app, app.config['API_LOCATION'], app.config['APP_SCHEME'])
api = Api(app=app, version='0.1', title='MReport Api', description='Test API', validate=True) #,doc=False

store = api.namespace('store', description='Store de dataviz')
Expand Down
4 changes: 3 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
DEBUG = True
APP_PREFIX = '/api'
API_LOCATION = '/api'
APP_SCHEME = 'http'
SQLALCHEMY_DATABASE_URI = 'sqlite:///data.db'
SQLALCHEMY_TRACK_MODIFICATIONS = False
SCHEMA = "data" ## Comment this line if you don't need schema or if you use SQLite
MREPORT_REPORTS = "backend/reports"
MREPORT_LOCATION = "/mreport"
ADMIN_LOCATION = "/admin"
3 changes: 2 additions & 1 deletion dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
from werkzeug.serving import run_simple
from frontend import app as front
from backend import app as back
from config import API_LOCATION

application = DispatcherMiddleware(front, {'/api': back })
application = DispatcherMiddleware(front, {API_LOCATION: back })

if __name__ == '__main__':
run_simple(
Expand Down
6 changes: 4 additions & 2 deletions frontend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

#def create_app(test_config=None):
app = Flask(__name__)
app.register_blueprint(admin)
app.register_blueprint(mreport)
app.config.from_object('config')
app.config['JSON_AS_ASCII'] = False
app.register_blueprint(admin, url_prefix=app.config['ADMIN_LOCATION'])
app.register_blueprint(mreport, url_prefix=app.config['MREPORT_LOCATION'])

# return app
4 changes: 2 additions & 2 deletions frontend/admin.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from flask import Blueprint, render_template

admin = Blueprint('admin', __name__, url_prefix='/admin', template_folder='templates',
admin = Blueprint('admin', __name__, template_folder='templates',
static_url_path='/static', static_folder='static')

@admin.route('/')
def index():
def index():
return render_template('admin.html')
2 changes: 1 addition & 1 deletion frontend/mreport.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from flask import Blueprint, render_template, send_from_directory, abort

mreport = Blueprint('mreport', __name__, url_prefix='/mreport', template_folder='templates',
mreport = Blueprint('mreport', __name__, template_folder='templates',
static_url_path='/static', static_folder='static')

#COMMON INDEX.HTML
Expand Down

0 comments on commit f9b5dca

Please sign in to comment.