Py.Cafe

iisakkirotko/

solara-interactive-voting

Interactive Voting System

DocsPricing
  • app.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import solara
import solara.lab


@solara.component
def CustomMessage(id: int, content: str = ""):
    def upvote():
        print("UP!", id)

    def downvote():
        print("DOWN!", id)

    solara.Markdown(content)
    with solara.Row():
        solara.Button("up", on_click=upvote)
        solara.Button("down", on_click=downvote)


@solara.component
def Page():
    for i in range(3):
        CustomMessage(content=f"message {i}", id=i)