-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
39 lines (30 loc) · 1.04 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
"""
File: server.py
Version: 1.0.0.0
Author: Ahmed Elsayed.
License: MIT.
Description: the entry point of the app that starts http server and listens to all requests
on port specified in the config file.
"""
import http.server
import config
from requests_handler import RequestHandler
from utilities.logger import Logger
def run(host, port):
log = Logger()
try:
# create http server.
server = http.server.HTTPServer((host, port), RequestHandler)
print(f"Geocoding Proxy Service - v{config.service_version}")
print(f"Server Started on port :{port}")
# log the start of the server.
log.log_info(f"Server Started on port :{str(port)}")
# listen for ever.
server.serve_forever()
except Exception as ex:
# in case of exception, log the incident as critical.
msg = f"Server Start error - {str(ex)}"
log.log_critical(msg)
exit(1)
# run the server
run('', config.server_port)