-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
61 lines (39 loc) · 1.62 KB
/
Copy pathmain.py
File metadata and controls
61 lines (39 loc) · 1.62 KB
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
# -------------------- Imports --------------------
import os
from flask import Flask
from flask_restful import Api
from application.config import LocalDevelopmentConfig
from application.database import db
from flask_cors import CORS
# -------------------- Initialization --------------------
app = None
api = None
def create_app():
app = Flask(__name__, template_folder="templates")
CORS(app)
if os.getenv('ENV', "development") == "production":
raise Exception("Currently no production config is setup.")
else:
print("Staring Local Development")
app.config.from_object(LocalDevelopmentConfig)
db.init_app(app)
api = Api(app)
app.app_context().push()
return app, api
app, api = create_app()
# Importing all the controllers so they are loaded
'''If this line is put at the start(i.e. if it is executed
before the creation of the Flask instance), it will create a
problem related to app.app_context'''
from application.controllers import *
# Importing all the restful controllers
from application.api import *
# -------------------- Adding the resources to the API --------------------
api.add_resource(ShowApi, '/api/show/<int:show_id>','/api/show')
api.add_resource(VenueApi, '/api/venue/<int:venue_id>','/api/venue')
api.add_resource(ShowDisplayApi, '/api/show/<int:show_id>/display')
api.add_resource(VenueDisplayApi, '/api/venue/<int:venue_id>/display')
# -------------------- Main --------------------
if __name__ == "__main__":
app.run(debug=True)
# -------------------- End --------------------