-
Notifications
You must be signed in to change notification settings - Fork 1
/
__init__.py
50 lines (37 loc) · 1.17 KB
/
__init__.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
import connexion
import errno
import sys
from flask_cors import CORS
from app.config import config
from app.data import data
from app.pluginCollection import pluginCollection
import app.templateFilters as templateFilters
def initApp() -> connexion:
"""
Initialize Connexion/Flask Application
Returns
-------
connexion
Connexion app instance
"""
# Create the application instance
app = connexion.App("Hackspace Status API", specification_dir='./')
# Read the openapi yaml file to configure the endpoints
app.add_api('api/openapi3.yaml', options={"swagger_ui": False})
# Add CORS support
CORS(app.app)
# Initialize own jinja2 filters
templateFilters.initialize(app)
# Initialize plugins
try:
pluginCollection()
except LookupError:
sys.exit(errno.EINTR)
print('Hackspace Status API started successfully')
return app
if __name__ == '__main__':
# Start application directly if we're running in stand alone mode
initApp().run(host='0.0.0.0', port=5000, debug=True, threaded=True)
else:
# Start application and set app context for running on wsgi servers
app = initApp()