-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathapp.py
35 lines (28 loc) · 900 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
# Copyright 2017, Dell EMC, Inc.
import atexit
import connexion
from flask import current_app
from util import util
config = util.load_config()
context = util.setup_ssl_context(config)
app = connexion.App(__name__, specification_dir='./swagger/')
app.add_api('swagger.yaml', arguments={'title': 'UCS Service'})
# Global handlers in current_app.config are used to minimize UCSM login/logout operations
with app.app.app_context():
current_app.config['handlers'] = {}
@atexit.register
def cleanup():
"""
App clean up
"""
with app.app.app_context():
handlers = current_app.config.get("handlers")
util.cleanup_ucs_handler(handlers)
print "Global handlers for connexion/flask app are cleared"
if __name__ == '__main__':
app.run(
host=config['address'],
port=config['port'],
debug=config['debug'],
ssl_context=context
)