master
km0 2 years ago
parent e0cda17ed0
commit c277f1820d

1
.gitignore vendored

@ -1,2 +1,3 @@
venv/
.DS_Store
__pycache__

@ -1,7 +1,10 @@
from flask import Flask, render_template, send_from_directory
from markdown import markdown
from prefix import PrefixMiddleware
app = Flask(__name__)
app.wsgi_app = PrefixMiddleware(app.wsgi_app, prefix='/soupboat/wlist')
@app.route('/')
def list():
@ -14,4 +17,4 @@ def list():
def send_img(file):
return send_from_directory(app.root_path + '/img/', file, conditional=True)
app.run(port="3000", debug=True)
app.run(port="3148", debug=True)

@ -0,0 +1,14 @@
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()]
Loading…
Cancel
Save