feat: return 404 when static file not found for requested route
This commit is contained in:
parent
e1c3358d61
commit
8512e7cf81
1 changed files with 7 additions and 4 deletions
11
web.py
11
web.py
|
@ -32,10 +32,13 @@ def home():
|
||||||
|
|
||||||
@app.route('/<path:path>')
|
@app.route('/<path:path>')
|
||||||
def dist(path):
|
def dist(path):
|
||||||
if '.' in path:
|
try:
|
||||||
return send_from_directory('dist', path)
|
if '.' in path:
|
||||||
else:
|
return send_from_directory('dist', path)
|
||||||
return send_from_directory('dist', path + '/index.html')
|
else:
|
||||||
|
return send_from_directory('dist', path + '/index.html')
|
||||||
|
except:
|
||||||
|
return send_from_directory('dist', '404.html'), 404
|
||||||
|
|
||||||
@app.errorhandler(404)
|
@app.errorhandler(404)
|
||||||
def not_found(e):
|
def not_found(e):
|
||||||
|
|
Loading…
Reference in a new issue