add reset endpoint. Change scoreboard to be default landing site.
This commit is contained in:
parent
586014e23c
commit
ef362a26cc
1 changed files with 30 additions and 2 deletions
32
app.py
32
app.py
|
|
@ -74,13 +74,13 @@ def update_player(player_id, name=None, score=None):
|
|||
conn.commit()
|
||||
|
||||
# Web Routes
|
||||
@app.route('/')
|
||||
@app.route('/input')
|
||||
def input_page():
|
||||
"""Mobile-friendly score input page"""
|
||||
players = get_all_players()
|
||||
return render_template('input.html', players=players)
|
||||
|
||||
@app.route('/scoreboard')
|
||||
@app.route('/')
|
||||
def scoreboard():
|
||||
"""TV display scoreboard page"""
|
||||
players = get_players_by_score() # Sort by score for display
|
||||
|
|
@ -129,6 +129,34 @@ def events():
|
|||
}
|
||||
)
|
||||
|
||||
@app.route('/reset', methods=['GET', 'POST'])
|
||||
def reset_database():
|
||||
"""Reset database to initial state"""
|
||||
try:
|
||||
with sqlite3.connect('database.db') as conn:
|
||||
# Clear existing data
|
||||
conn.execute('DELETE FROM players')
|
||||
|
||||
# Re-initialize with default players
|
||||
for i in range(1, 15):
|
||||
conn.execute(
|
||||
'INSERT INTO players (id, name, score) VALUES (?, ?, ?)',
|
||||
(i, f'Player {i}', 0)
|
||||
)
|
||||
conn.commit()
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'message': 'Database reset successfully',
|
||||
'players_created': 14
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'error': str(e)
|
||||
}), 500
|
||||
|
||||
if __name__ == '__main__':
|
||||
init_db()
|
||||
app.run(host='0.0.0.0', port=8080, debug=True)
|
||||
|
|
|
|||
Loading…
Reference in a new issue