kbberendsen commited on
Commit
75b2bb3
1 Parent(s): 84b4aa4

new layout and options plus a lot of cached data

Browse files
Files changed (1) hide show
  1. app.py +20 -14
app.py CHANGED
@@ -16,32 +16,40 @@ import shinyswatch
16
  cache_path = os.getcwd() + "/cache"
17
 
18
  ff1.Cache.enable_cache(cache_path)
19
- ff1.Cache.offline_mode(enabled=True)
20
 
21
  print(f"Cache path: {cache_path}")
22
 
23
- app_ui = x.ui.page_fillable(
24
  shinyswatch.theme.minty(),
25
- x.ui.layout_sidebar(
26
- x.ui.sidebar(
27
  ui.input_select(
28
  "track", label="Select track:",
29
  choices=["Austria", "Hungary", "Spain", "Bahrain"],
30
  selected = "Austria"),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  ),
32
- ui.h3("Gear usage in fastest lap"),
33
- x.ui.output_plot("gear", fill = True),
34
- ui.output_text("fastest_driver"),
35
-
36
- fill=True,
37
- fillable=True,
38
  ),
39
- )
40
 
41
  def server(input, output, session):
42
  @reactive.Calc
43
  def get_data():
44
- f1_session = ff1.get_session(2023, input.track(), 'R')
45
  f1_session.load()
46
 
47
  lap = f1_session.laps.pick_fastest()
@@ -86,8 +94,6 @@ def server(input, output, session):
86
  @render.text
87
  def fastest_driver():
88
  segments, gear, driver = get_data()
89
-
90
- print(driver)
91
  return f"The driver of the fastest lap is: {driver}"
92
 
93
 
 
16
  cache_path = os.getcwd() + "/cache"
17
 
18
  ff1.Cache.enable_cache(cache_path)
19
+ #ff1.Cache.offline_mode(enabled=True)
20
 
21
  print(f"Cache path: {cache_path}")
22
 
23
+ app_ui = ui.page_fluid(
24
  shinyswatch.theme.minty(),
25
+ ui.layout_sidebar(
26
+ ui.panel_sidebar(
27
  ui.input_select(
28
  "track", label="Select track:",
29
  choices=["Austria", "Hungary", "Spain", "Bahrain"],
30
  selected = "Austria"),
31
+ ui.input_radio_buttons(
32
+ "session_type", "Session type:",
33
+ choices = {"R": "Race", "Q": "Qualification"},
34
+ selected = "R"),
35
+ ui.input_radio_buttons(
36
+ "year", "Year:",
37
+ choices = [2023, 2022],
38
+ selected = 2023),
39
+ ),
40
+
41
+ ui.panel_main(
42
+ ui.h3("Gear usage in fastest lap"),
43
+ x.ui.output_plot("gear", fill = True),
44
+ ui.output_text("fastest_driver")
45
  ),
 
 
 
 
 
 
46
  ),
47
+ )
48
 
49
  def server(input, output, session):
50
  @reactive.Calc
51
  def get_data():
52
+ f1_session = ff1.get_session(int(input.year()), input.track(), input.session_type())
53
  f1_session.load()
54
 
55
  lap = f1_session.laps.pick_fastest()
 
94
  @render.text
95
  def fastest_driver():
96
  segments, gear, driver = get_data()
 
 
97
  return f"The driver of the fastest lap is: {driver}"
98
 
99