vinay-jose commited on
Commit
6462c0c
·
verified ·
1 Parent(s): ace03e7

Added hx_swap

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -1,15 +1,14 @@
1
  from fasthtml.common import *
2
  import random
3
 
4
- app,rt = fast_app()
5
 
6
- @rt('/')
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()