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 • 609 B
Python script, ASCII text executable
        
            
1
from flask import Flask, send_file as SendFile
2
from os.path import exists as PathExists, join as JoinPath, isfile
3
from os import getcwd
4
5
app = Flask(__name__)
6
7
@app.route("/")
8
def Index():
9
return SendFile("../index.html")
10
11
@app.route("/<path:path>")
12
def Other(path):
13
FindFile = JoinPath(getcwd(), path).replace("\\", "/")
14
if not isfile(FindFile):
15
return SendFile(JoinPath(FindFile, "index.html").replace("\\", "/"))
16
elif PathExists(FindFile):
17
return SendFile(FindFile)
18
return SendFile("../404.html"), 404
19
20
if __name__ == "__main__":
21
app.run("0.0.0.0", 9000, debug=True)