gets rid of __init__ and runserver in favor of new modular design also introduces db model, first api endpoints, as well as their wrappers
44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
from flask import render_template, request, make_response
|
|
import lewy_globals
|
|
|
|
def index():
|
|
dark_mode = request.cookies.get('darkMode', 'disabled')
|
|
stats = {
|
|
'goals': 38,
|
|
'assists': 12,
|
|
'matches': 45,
|
|
'matches_list': [
|
|
{'date': '2024-10-12', 'opponent': 'Real Madrid', 'goals': 2, 'assists': 1, 'minutes': 90},
|
|
{'date': '2024-10-19', 'opponent': 'Valencia', 'goals': 1, 'assists': 0, 'minutes': 85},
|
|
# Możesz dodać więcej meczów...
|
|
]
|
|
}
|
|
return render_template('index.html', goals=stats['goals'], assists=stats['assists'],
|
|
matches=stats['matches'], matches_list=stats['matches_list'],
|
|
commit_in_html=lewy_globals.getCommitInFormattedHTML(),
|
|
dark_mode=dark_mode)
|
|
|
|
def mecze():
|
|
# Możesz dostarczyć szczegóły dotyczące meczów
|
|
matches = [
|
|
{'date': '2024-10-12', 'opponent': 'Real Madrid', 'goals': 2, 'assists': 1, 'minutes': 90},
|
|
{'date': '2024-10-19', 'opponent': 'Valencia', 'goals': 1, 'assists': 0, 'minutes': 85},
|
|
]
|
|
return render_template('matches.html', matches=matches)
|
|
|
|
def statystyki():
|
|
stats = {
|
|
'goals': 38,
|
|
'assists': 12,
|
|
'matches': 45,
|
|
}
|
|
return render_template('stats.html', stats=stats)
|
|
|
|
def toggle_dark_mode():
|
|
# Przełącz tryb i zapisz w ciasteczku
|
|
dark_mode = request.cookies.get('darkMode', 'disabled')
|
|
new_mode = 'enabled' if dark_mode == 'disabled' else 'disabled'
|
|
response = make_response("OK")
|
|
response.set_cookie('darkMode', new_mode, max_age=31536000) # Ustawienie ciasteczka na 1 rok
|
|
return response
|