formula1 / modules /test_module.py
kbberendsen's picture
testing module
22210e9
raw
history blame contribute delete
726 Bytes
import os
from shiny import module, App, ui, render, reactive
import fastf1 as ff1
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
from matplotlib import cm
import numpy as np
import shinyswatch
@module.ui
def test_ui():
return ui.div(
ui.h2("Number + 5"),
ui.input_text(id="num_input", label="Enter number:"),
ui.output_text_verbatim(id="answer"),
)
@module.server
def test_server(input, output, session):
@reactive.Calc
def calculation():
try:
return int(input.num_input()) + 5
except:
return "..."
@output
@render.text
def answer():
return f"The answer is {calculation()}"