Skip to content
Snippets Groups Projects
Commit 92745363 authored by Joseph Weston's avatar Joseph Weston
Browse files

make index function more pythonic

parent 4d42d05b
Branches
Tags
No related merge requests found
from os import path
from os.path import abspath, dirname, isfile
from werkzeug.exceptions import NotFound
from flask import Flask
from flask_basicauth import BasicAuth
......@@ -7,8 +9,7 @@ from . import db, api
static_folder_path = path.join(abspath(dirname(__file__)), 'static')
app = Flask(__name__,
static_folder= static_folder_path)
app = Flask(__name__, static_folder=static_folder_path)
db.use_db()
......@@ -23,7 +24,8 @@ app.register_blueprint(api.app, url_prefix='/api')
@app.route('/')
@app.route('/<file>')
def index(file=''):
if not isfile(path.join(static_folder_path, file)):
file = 'index.html'
return app.send_static_file(file)
\ No newline at end of file
def index(file='index.html'):
try:
return app.send_static_file(file)
except NotFound:
return app.send_static_file('index.html')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment