forked from PnX-SI/TaxHub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
67 lines (47 loc) · 1.8 KB
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# coding: utf8
from flask import Flask, request, current_app
from flask_sqlalchemy import SQLAlchemy
from flask_cors import CORS
import importlib
import datetime
from apptax.database import db
db = db
app_globals = {}
def init_app():
if app_globals.get('app', False):
app = app_globals['app']
else:
app = Flask(__name__)
with app.app_context():
app.config.from_pyfile('config.py')
db.init_app(app)
db.app = app
app.config['DB'] = db
@app.teardown_request
def _manage_transaction(exception):
if exception:
db.session.rollback()
else:
db.session.commit()
db.session.remove()
from pypnusershub import routes
app.register_blueprint(routes.routes, url_prefix='/api/auth')
from apptax.index import routes
app.register_blueprint(routes, url_prefix='/')
from apptax.taxonomie.routesbibnoms import adresses
app.register_blueprint(adresses, url_prefix='/api/bibnoms')
from apptax.taxonomie.routestaxref import adresses
app.register_blueprint(adresses, url_prefix='/api/taxref')
from apptax.taxonomie.routesbibattributs import adresses
app.register_blueprint(adresses, url_prefix='/api/bibattributs')
from apptax.taxonomie.routesbiblistes import adresses
app.register_blueprint(adresses, url_prefix='/api/biblistes')
from apptax.taxonomie.routestmedias import adresses
app.register_blueprint(adresses, url_prefix='/api/tmedias')
from apptax.taxonomie.routesbibtypesmedia import adresses
app.register_blueprint(adresses, url_prefix='/api/bibtypesmedia')
return app
app = init_app()
CORS(app, supports_credentials=True)
if __name__ == '__main__':
app.run()