from fasthtml.common import *
from fasthtml.jupyter import *
from fh_commons.core import *
from fh_commons.static import *
import json
import pandas as pd
from math import ceil
Routes
Setup
from ngrok_token import *
= start_ngrok(token)
url
= fast_app(pico=False,hdrs=hdrs)
app,rt = JupyUvi(app) server
Routes
@rt
Both get and post method, function name is the route’s name
@rt
def test():
return P('hi')
@rt(‘/sth’)
If function name is get or post, then would be either of the method.
If function name is something else, would not change the route, but specify the route name
@rt('/something')
def get(): return P('hi')
With params:
@rt('/something/{data}')
def get(data:str): return P(data)
'/something/sdf') htmx(url,
Use function to indicate route’s name
@rt('/something')
def sdfsdf(req):
return P(req.url_for('sdfsdf'))
With route’s name
@rt('/something',name='aaa')
def get(req):
return P(req.url_for('aaa'))
@app.get/post
Similar to @rt, the function name indicates route
@app.get
def asdf():
return P('hi')
@app.get(‘/something’)
@app.get('/user/{nm}')
def get_nm(nm:str): return f"Good day to you, {nm}!"
End
server.stop() kill_ngrok()