forked from Zhen-Bo/flipper_gacha_simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwsgi.py
24 lines (16 loc) · 735 Bytes
/
wsgi.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
from flipper_gacha import app
class PrefixMiddleware(object):
def __init__(self, app, prefix=""):
self.app = app
self.prefix = prefix
def __call__(self, environ, start_response):
if environ["PATH_INFO"].startswith(self.prefix):
environ["PATH_INFO"] = environ["PATH_INFO"][len(self.prefix) :]
environ["SCRIPT_NAME"] = self.prefix
return self.app(environ, start_response)
else:
start_response("404", [("Content-Type", "text/plain")])
return ["This url does not belong to the app.".encode()]
app.wsgi_app = PrefixMiddleware(app.wsgi_app, prefix="/wf")
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000, debug=True)