Spaces:
Sleeping
Sleeping
Added hx_swap
Browse files
app.py
CHANGED
@@ -1,15 +1,14 @@
|
|
1 |
from fasthtml.common import *
|
2 |
import random
|
3 |
|
4 |
-
app
|
5 |
|
6 |
-
@
|
7 |
-
def get(): return Div(P('Hello World!'), hx_get="/change")
|
8 |
-
|
9 |
-
@rt('/change')
|
10 |
|
|
|
11 |
def get():
|
12 |
texts = ['Nice to be here!', 'Hello World!', 'It\'s so random!']
|
13 |
return Div(P(random.choice(texts)), hx_get="/change")
|
14 |
|
15 |
-
serve()
|
|
|
1 |
from fasthtml.common import *
|
2 |
import random
|
3 |
|
4 |
+
app = FastHTML()
|
5 |
|
6 |
+
@app.route('/')
|
7 |
+
def get(): return Div(P('Hello World!'), hx_get="/change", hx_swap="beforebegin")
|
|
|
|
|
8 |
|
9 |
+
@app.route('/change')
|
10 |
def get():
|
11 |
texts = ['Nice to be here!', 'Hello World!', 'It\'s so random!']
|
12 |
return Div(P(random.choice(texts)), hx_get="/change")
|
13 |
|
14 |
+
# serve()
|