forked from RackHD/ucs-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
39 lines (33 loc) · 1.08 KB
/
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
# Copyright 2017, Dell EMC, Inc.
import connexion
import json
if __name__ == '__main__':
defaults = {
"address": "0.0.0.0",
"port": 7080,
"httpsEnabled": False,
"certFile": None,
"keyFile": None,
"debug": False,
}
# load config info
try:
with open('config.json') as config_data:
config = json.load(config_data)
except:
print("Error loading config.json, using defaults!")
config = defaults
# set up ssl_context
if 'httpsEnabled' not in config or not config['httpsEnabled']:
context = None
elif 'certFile' not in config or config['certFile'] is None or \
'keyFile' not in config or config['keyFile'] is None:
context = 'adhoc'
else:
context = (config['certFile'], config['keyFile'])
app = connexion.App(__name__, specification_dir='./swagger/')
app.add_api('swagger.yaml', arguments={'title': 'UCS Service'})
app.run(host=config['address'],
port=config['port'],
debug=config['debug'],
ssl_context=context)