-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
46 lines (31 loc) · 1.3 KB
/
server.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
from bottle import Bottle, run, request, response, static_file
from app import App
bottle_app = Bottle()
dataApp = App()
@bottle_app.hook('before_request')
def strip_path():
request.environ['PATH_INFO'] = request.environ['PATH_INFO'].rstrip('/')
@bottle_app.hook('after_request')
def enable_cors():
response.headers['Access-Control-Allow-Origin'] = '*'
response.headers['Access-Control-Allow-Methods'] = 'GET'
response.headers['Access-Control-Allow-Headers'] = 'Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token'
@bottle_app.route('/iss/api')
def server_static(filename='index.html'):
return static_file(filename, root='.')
@bottle_app.route('/iss/api/swagger.yaml')
def server_swagger_yaml(filename='swagger.yaml'):
return static_file(filename, root='.')
@bottle_app.route('/iss/api/swagger/<filepath:path>')
def server_swagger(filepath):
return static_file(filepath, root='./swagger/')
@bottle_app.route('/iss')
def get_data():
(output_format, filename, data) = dataApp.get_data(request)
response.content_type = output_format
response.headers['Content-Disposition'] = 'attachment; filename="%s"' % (filename)
return data
def main():
run(bottle_app, host='0.0.0.0', port=8104, server="gunicorn", workers=5, timeout=900)
if __name__ == '__main__':
main()