A mirror of my website's source code.

By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

 local-server.py

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