From 6468ac7c2d56e50ded62ea4054d90ebac305bf3a Mon Sep 17 00:00:00 2001 From: Roosted7 <thomasroos@live.nl> Date: Tue, 16 Jan 2018 23:25:43 +0100 Subject: [PATCH] Fix client side router fallback --- zesje/__init__.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/zesje/__init__.py b/zesje/__init__.py index ee839b034..bffcb8ad3 100644 --- a/zesje/__init__.py +++ b/zesje/__init__.py @@ -1,16 +1,21 @@ from os import path -from os.path import abspath, dirname +from os.path import abspath, dirname, isfile from flask import Flask from . import db, api +static_folder_path = path.join(abspath(dirname(__file__)), 'static') + app = Flask(__name__, - static_folder=path.join(abspath(dirname(__file__)), 'static')) + static_folder= static_folder_path) db.use_db() app.register_blueprint(api.app, url_prefix='/api') @app.route('/') @app.route('/<file>') -def index(file=None): - return app.send_static_file(file or 'index.html') +def index(file=''): + if (isfile(path.join(static_folder_path, file))): + return app.send_static_file(file) + else: + return app.send_static_file('index.html') \ No newline at end of file -- GitLab