-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path07_navigation.py
More file actions
60 lines (48 loc) · 1.67 KB
/
Copy path07_navigation.py
File metadata and controls
60 lines (48 loc) · 1.67 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""Navigation between pages with links and buttons."""
from fastui import App, ui
app = App()
@app.page("/", title="Home")
def home():
return [
ui.heading("Navigation Demo", level=1),
ui.text("Click around to see navigation in action."),
ui.divider(),
ui.link("Go to About", url="/about", style="display: block; margin: 0.5rem 0;"),
ui.link("Go to Contact", url="/contact", style="display: block; margin: 0.5rem 0;"),
ui.link("Go to FAQ", url="/faq", style="display: block; margin: 0.5rem 0;"),
ui.divider(),
ui.text("You can also use buttons:"),
ui.button("Go to About", on_click="/about"),
ui.button("Go to Contact", on_click="/contact"),
]
@app.page("/about", title="About")
def about():
return [
ui.heading("About", level=1),
ui.text("FastUI lets you build web UIs entirely in Python."),
ui.divider(),
ui.link("← Back to Home", url="/"),
]
@app.page("/contact", title="Contact")
def contact():
return [
ui.heading("Contact", level=1),
ui.text("Email: hello@fastui.dev"),
ui.text("GitHub: github.com/fastui"),
ui.divider(),
ui.link("← Back to Home", url="/"),
]
@app.page("/faq", title="FAQ")
def faq():
return [
ui.heading("FAQ", level=1),
ui.text("Q: What is FastUI?"),
ui.text("A: A Python library for building UI with decorators."),
ui.divider(),
ui.text("Q: Does it require JavaScript?"),
ui.text("A: No — everything compiles to plain HTML."),
ui.divider(),
ui.link("← Back to Home", url="/"),
]
if __name__ == "__main__":
app.run()