-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
39 lines (28 loc) · 846 Bytes
/
app.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
from flask import Flask, g
from resp import *
from model import database
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
@app.errorhandler(400)
def handle_400(err):
return error('Invalid JSON body')
@app.before_request
def before_request():
# Do connect database
g.db = database
g.db.connect()
@app.after_request
def after_request(response):
g.db.close()
return response
# Here for register BluePrint routes
from views import users, teams, projects, tasks
app.register_blueprint(users.module, url_prefix="/api/v1/users")
app.register_blueprint(teams.module, url_prefix="/api/v1/teams")
app.register_blueprint(projects.module, url_prefix="/api/v1/projects")
app.register_blueprint(tasks.module, url_prefix="/api/v1/tasks")
if __name__ == "__main__":
app.debug=True
app.run()