-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
38 lines (33 loc) · 1.09 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
from src.example.ExampleRouter import exampleRouter
from src.calculator.calculatorRouter import calculatorRouter
from src.status.statusRouter import statusRouter
import cherrypy
import os
port = int(os.getenv('PORT', '8080'))
print("PORT: ", port)
# checking if the program in running on heroku
autoReload = False if os.getenv('FORWARDED_ALLOW_IPS') else True
print("AUTORELOAD: ", autoReload)
# for pining all env
# for item, value in os.environ.items():
# print('{}: {}'.format(item, value))
conf = {
'/': {
'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
'tools.sessions.on': True,
'tools.response_headers.on': True,
'tools.response_headers.headers': [('Content-Type', 'text/plain')]
}
}
baseAPI = "/api"
globalConf = {
'server.socket_port': port,
'server.socket_host': '0.0.0.0',
'engine.autoreload.on': autoReload
}
if __name__ == '__main__':
cherrypy.config.update(globalConf)
statusRouter("/", "", conf)
exampleRouter(baseAPI, "/example", conf)
calculatorRouter(baseAPI, "/calculator", conf)
cherrypy.engine.block()