File size: 726 Bytes
22210e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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()}"