10-detect-empty-db #29
15
app/app.py
15
app/app.py
@@ -84,7 +84,20 @@ def podStatus():
|
||||
# Index route
|
||||
@app.route('/')
|
||||
def index():
|
||||
return redirect('/events')
|
||||
# Check for empty database, go to setup page if not setup
|
||||
global tablesSetup
|
||||
required_tables = ['period', 'task', 'event', 'user']
|
||||
for table in required_tables:
|
||||
if table in db.metadata.tables:
|
||||
tablesSetup = True
|
||||
else:
|
||||
tablesSetup = False
|
||||
break
|
||||
if not tablesSetup:
|
||||
return ""
|
||||
# Otherwise, redirect to /events
|
||||
else:
|
||||
return redirect('/events')
|
||||
|
||||
# Authentication routes
|
||||
@app.route('/login', methods=['GET', 'POST'])
|
||||
|
Reference in New Issue
Block a user