You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.0 KiB
Python

# Boiler inspection form #
from flask import Flask, render_template, request, redirect
# ----- FLASK ----- #
# prefix middleware
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()]
# initialize flask app
app = Flask(__name__)
app.wsgi_app = PrefixMiddleware(app.wsgi_app, prefix='/boiler-inspection')
@app.route("/")
def home():
return render_template("copy1.html")
@app.route("/copy2")
def copy2():
return render_template("copy2.html")
@app.route("/report")
def report():
return render_template("report.html")
app.run ()