kbberendsen commited on
Commit
22210e9
1 Parent(s): a582e94

testing module

Browse files
__pycache__/app.cpython-311.pyc CHANGED
Binary files a/__pycache__/app.cpython-311.pyc and b/__pycache__/app.cpython-311.pyc differ
 
app.py CHANGED
@@ -7,6 +7,7 @@ from matplotlib import cm
7
  import numpy as np
8
  import shinyswatch
9
  from modules import plot
 
10
 
11
  # Define cache folder path
12
  cache_path = os.getcwd() + "/cache"
@@ -84,7 +85,8 @@ app_ui = ui.page_fluid(
84
  ui.row(
85
  ui.column(
86
  6,
87
- plot.plot1_ui("gear_1")
 
88
  #ui.output_text("fastest_driver_1"),
89
  #ui.output_text("laptime_1")
90
  ),
@@ -101,6 +103,8 @@ app_ui = ui.page_fluid(
101
 
102
  def server(input, output, session):
103
 
 
 
104
  # Updating driver selection list
105
  @reactive.Effect()
106
  def _():
@@ -155,7 +159,7 @@ def server(input, output, session):
155
  @output
156
  @render.text
157
  def fastest_driver_1():
158
- segments, gear, driver, lap_time = plot.plot1_server("get_data_1")
159
  #print(f"The driver of the fastest lap this session is: {driver}")
160
  return f"Graph shows the fastest lap of: {driver}"
161
 
@@ -169,7 +173,7 @@ def server(input, output, session):
169
  @output
170
  @render.text
171
  def laptime_1():
172
- segments, gear, driver, lap_time = plot.plot1_server("get_data_1")
173
  delta_str= str(lap_time)
174
  # Split the time delta string to extract hours, minutes, and seconds
175
  time_parts = delta_str.split(" ")[-1].split(":")
 
7
  import numpy as np
8
  import shinyswatch
9
  from modules import plot
10
+ from modules import test_module
11
 
12
  # Define cache folder path
13
  cache_path = os.getcwd() + "/cache"
 
85
  ui.row(
86
  ui.column(
87
  6,
88
+ test_module.test_ui("calc_1")
89
+ #plot.plot1_ui("gear_1")
90
  #ui.output_text("fastest_driver_1"),
91
  #ui.output_text("laptime_1")
92
  ),
 
103
 
104
  def server(input, output, session):
105
 
106
+ test_module.test_server("calc_1")
107
+
108
  # Updating driver selection list
109
  @reactive.Effect()
110
  def _():
 
159
  @output
160
  @render.text
161
  def fastest_driver_1():
162
+ segments, gear, driver, lap_time = plot.plot1_server("gear_1")
163
  #print(f"The driver of the fastest lap this session is: {driver}")
164
  return f"Graph shows the fastest lap of: {driver}"
165
 
 
173
  @output
174
  @render.text
175
  def laptime_1():
176
+ segments, gear, driver, lap_time = plot.plot1_server("gear_1")
177
  delta_str= str(lap_time)
178
  # Split the time delta string to extract hours, minutes, and seconds
179
  time_parts = delta_str.split(" ")[-1].split(":")
modules/__pycache__/test_module.cpython-311.pyc ADDED
Binary file (2.01 kB). View file
 
modules/test_module.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from shiny import module, App, ui, render, reactive
3
+ import fastf1 as ff1
4
+ import matplotlib.pyplot as plt
5
+ from matplotlib.collections import LineCollection
6
+ from matplotlib import cm
7
+ import numpy as np
8
+ import shinyswatch
9
+
10
+ @module.ui
11
+ def test_ui():
12
+ return ui.div(
13
+ ui.h2("Number + 5"),
14
+ ui.input_text(id="num_input", label="Enter number:"),
15
+ ui.output_text_verbatim(id="answer"),
16
+ )
17
+
18
+
19
+ @module.server
20
+
21
+ def test_server(input, output, session):
22
+ @reactive.Calc
23
+ def calculation():
24
+ try:
25
+ return int(input.num_input()) + 5
26
+ except:
27
+ return "..."
28
+
29
+ @output
30
+ @render.text
31
+ def answer():
32
+ return f"The answer is {calculation()}"