forked from dataforgoodfr/peer-session-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
31 lines (26 loc) · 1006 Bytes
/
main.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
import os
import logging
from http.server import HTTPServer
from peer_session_3 import upserver
# Set up logger
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
host_name = "0.0.0.0"
server_port = 8081
logger.debug("Got the following environment variables:")
logger.debug(f"DATABASE_HOST: {os.environ.get('DATABASE_HOST')}")
logger.debug(f"DATABASE_PORT: {os.environ.get('DATABASE_PORT')}")
logger.debug(f"POSTGRES_DB: {os.environ.get('POSTGRES_DB')}")
logger.debug(f"POSTGRES_USER: {os.environ.get('POSTGRES_USER')}")
logger.debug(f"POSTGRES_PASSWORD: {os.environ.get('POSTGRES_PASSWORD')}")
if __name__ == "__main__":
logger.info("Starting the Webserver")
web_server = HTTPServer((host_name, server_port), upserver.UpServer)
logger.info(f"Server listening http://{host_name}:{server_port}")
try:
web_server.serve_forever()
except KeyboardInterrupt:
pass
finally:
web_server.server_close()
print("Server stopped.")