1
0
mirror of https://github.com/chubin/cheat.sh.git synced 2026-06-20 13:16:44 +02:00
Files
cheat.sh/bin/srv.py
2025-07-29 20:07:59 +02:00

30 lines
634 B
Python

#!/usr/bin/env python
#
# Serving cheat.sh with `gevent`
#
from gevent.monkey import patch_all
from gevent.pywsgi import WSGIServer
patch_all()
import os
import sys
from app import app, CONFIG
if "--debug" in sys.argv:
# Not all debug mode features are available under `gevent`
# https://github.com/pallets/flask/issues/3825
app.debug = True
if "CHEATSH_PORT" in os.environ:
port = int(os.environ.get("CHEATSH_PORT"))
else:
port = CONFIG["server.port"]
srv = WSGIServer((CONFIG["server.bind"], port), app)
print("Starting gevent server on {}:{}".format(srv.address[0], srv.address[1]))
srv.serve_forever()