david-clifford commited on
Commit
f6875cc
·
verified ·
1 Parent(s): a46d377
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -3,6 +3,7 @@ from fasthtml.common import *
3
  # using https://www.fastht.ml/docs/tutorials/by_example.html
4
  app,rt = fast_app(pico=True)
5
 
 
6
  ## Initial set of scores information
7
  scores = {
8
  # Team A
@@ -101,14 +102,19 @@ def index():
101
  return Titled('GAA Score Keeper',
102
  Div(
103
  P('Enter the team names'),
104
- Form(Input(name='team_A', value=team_A),
105
- Input(name='team_B', value=team_B),
106
  Button('Click'),
107
  hx_post='/set_table', hx_target='#main'),
108
  id='main'))
109
 
110
  @rt
111
- def set_table(team_A:str, team_B:str):
 
 
 
 
 
112
  return Main(
113
  Div(
114
  Table(
@@ -132,13 +138,13 @@ def set_table(team_A:str, team_B:str):
132
  ),
133
  Div(
134
  Button( Span("Undo"), hx_post="/reset_recent", hx_target='#main' ),
135
- Button( Span("Start Clock"), hx_post="/timer_toggle", hx_target='#timer_display' ),
136
  Button( Span("Full Reset"), hx_post="/reset", hx_target='#main' ),
137
  style = "display: flex; justify-content: space-between;"
138
  ),
139
  style="display: flex; flex-direction: column; min-height: 80vh;"
140
  )
141
-
142
  # Timer state
143
  timer_state = {
144
  'start_time': None,
 
3
  # using https://www.fastht.ml/docs/tutorials/by_example.html
4
  app,rt = fast_app(pico=True)
5
 
6
+ ## From HF
7
  ## Initial set of scores information
8
  scores = {
9
  # Team A
 
102
  return Titled('GAA Score Keeper',
103
  Div(
104
  P('Enter the team names'),
105
+ Form(Input(name='team_name_A', value=team_A),
106
+ Input(name='team_name_B', value=team_B),
107
  Button('Click'),
108
  hx_post='/set_table', hx_target='#main'),
109
  id='main'))
110
 
111
  @rt
112
+ def set_table(team_name_A:str, team_name_B:str):
113
+ global team_A
114
+ global team_B
115
+ team_A = team_name_A ## Update global
116
+ team_B = team_name_B ## Update global
117
+ print("set_table called"+team_A+team_B)
118
  return Main(
119
  Div(
120
  Table(
 
138
  ),
139
  Div(
140
  Button( Span("Undo"), hx_post="/reset_recent", hx_target='#main' ),
141
+ Button( Span("Toggle Clock"), hx_post="/timer_toggle", hx_target='#timer_display' ),
142
  Button( Span("Full Reset"), hx_post="/reset", hx_target='#main' ),
143
  style = "display: flex; justify-content: space-between;"
144
  ),
145
  style="display: flex; flex-direction: column; min-height: 80vh;"
146
  )
147
+
148
  # Timer state
149
  timer_state = {
150
  'start_time': None,