-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathserve.py
27 lines (23 loc) · 809 Bytes
/
serve.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
# gevent.monkey should be done as early as possible
from gevent import monkey
monkey.patch_all()
import os
import logging
from gevent import pywsgi
from logging.handlers import RotatingFileHandler
from app import create_app # this imports app
# create a file handler to store weblogs
os.makedirs("tmp", exist_ok=True)
handler = RotatingFileHandler("tmp/tmp.log", maxBytes=1000000000, backupCount=1)
handler.setLevel(logging.INFO)
formatter = logging.Formatter(
"[%(asctime)s] %(levelname)s {%(pathname)s:%(lineno)d} - %(message)s"
)
handler.setFormatter(formatter)
app = create_app()
app.logger.setLevel(logging.INFO)
app.logger.addHandler(handler)
# run the application
server = pywsgi.WSGIServer(("0.0.0.0", 8080), app)
app.logger.info("Serving at %s", "http://0.0.0.0:8080")
server.serve_forever()