local-server.py
Python script, ASCII text executable
1# This is a debugging server used for site development, it's not used on the actual site. 2 3from flask import Flask, send_file as SendFile 4from os.path import isfile 5from pathlib import Path 6 7FlaskOpts = {} 8app = Flask(__name__, **FlaskOpts) 9 10@app.route("/", defaults={"path": ""}) 11@app.route("/<path:path>") 12def SendStatic(path): 13if isfile("build/" + path): 14return SendFile(Path("build").joinpath(path)) 15elif isfile(Path("build").joinpath(path, "index.html")): 16return SendFile(Path("build").joinpath(path, "index.html")) 17return SendFile("build/404.html") 18 19if __name__ == "__main__": 20app.run("0.0.0.0", 8000, debug=True)