feat: Add searching for files before returning a 404
All checks were successful
Build Docker / BuildImage (push) Successful in 42s
All checks were successful
Build Docker / BuildImage (push) Successful in 42s
This commit is contained in:
parent
56349561f9
commit
9c0d592a24
16
server.py
16
server.py
@ -67,6 +67,11 @@ def getAddress(coin: str) -> str:
|
||||
address = file.read()
|
||||
return address
|
||||
|
||||
def find(name, path):
|
||||
for root, dirs, files in os.walk(path):
|
||||
if name in files:
|
||||
return os.path.join(root, name)
|
||||
|
||||
|
||||
# Assets routes
|
||||
@app.route("/assets/<path:path>")
|
||||
@ -765,7 +770,7 @@ def supersecretpath():
|
||||
|
||||
|
||||
@app.route("/<path:path>")
|
||||
def catch_all(path):
|
||||
def catch_all(path: str):
|
||||
global handshake_scripts
|
||||
# If localhost, don't load handshake
|
||||
if (
|
||||
@ -793,6 +798,15 @@ def catch_all(path):
|
||||
path.strip("/") + ".html", handshake_scripts=handshake_scripts, sites=sites
|
||||
)
|
||||
|
||||
# Try to find a file matching
|
||||
if path.count("/") < 1:
|
||||
# Try to find a file matching
|
||||
filename = find(path, "templates")
|
||||
if filename:
|
||||
return send_file(filename)
|
||||
|
||||
|
||||
|
||||
return render_template("404.html"), 404
|
||||
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 479 KiB |
Binary file not shown.
Before Width: | Height: | Size: 53 KiB |
Loading…
Reference in New Issue
Block a user