-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path13_multi_page.py
More file actions
66 lines (51 loc) · 1.63 KB
/
Copy path13_multi_page.py
File metadata and controls
66 lines (51 loc) · 1.63 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
61
62
63
64
65
66
"""Multi-page application with shared navigation layout."""
from fastui import App, ui
app = App()
def nav():
return ui.page([
ui.link("Home", url="/", style="margin-right: 1rem;"),
ui.link("Blog", url="/blog", style="margin-right: 1rem;"),
ui.link("About", url="/about", style="margin-right: 1rem;"),
ui.link("Contact", url="/contact"),
], style="padding: 1rem; background: #f0f0f0; border-radius: 8px; margin-bottom: 1rem;")
@app.page("/", title="Home")
def home():
return [
nav(),
ui.heading("Welcome", level=1),
ui.text("This is a multi-page site with shared navigation."),
]
@app.page("/blog", title="Blog")
def blog():
return [
nav(),
ui.heading("Blog", level=1),
ui.text("Blog posts will appear here."),
ui.link("Read: Hello World", url="/blog/hello-world"),
]
@app.page("/blog/{slug}", title="Post")
def blog_post(slug: str):
return [
nav(),
ui.heading(f"Post: {slug}", level=1),
ui.text(f"This is the content of '{slug}'."),
ui.link("← Back to Blog", url="/blog"),
]
@app.page("/about", title="About")
def about():
return [
nav(),
ui.heading("About", level=1),
ui.text("FastUI — build UIs with Python."),
]
@app.page("/contact", title="Contact")
def contact():
return [
nav(),
ui.heading("Contact", level=1),
ui.input(label="Name", name="name"),
ui.input(label="Message", name="msg", placeholder="Your message..."),
ui.button("Send (not yet implemented)", on_click="/"),
]
if __name__ == "__main__":
app.run()