По сути, у меня есть этот модуль Python FastHTML, который ссылается на гораздо больше маршрутов (здесь для простоты включены только 2 маршрута):
Код: Выделить всё
from fasthtml import common as fh
myHeaders = [
fh.Meta(charset='UTF-8'),
fh.Meta(name='viewport', content='width=device-width, initial-scale=1'),
fh.Link(rel='stylesheet', href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css')
]
# Creating FastAPI App
app = fh.FastHTML(hdrs=myHeaders,secret_key=xmother.newId(25))
# Mounting the static folder for accessing the menu.css
app.mount("/static", StaticFiles(directory="static"), name="static")
fh.serve()
# Defining the routes.
#=== I WANT TO SEPARATE THE FOLLOWING ROUTING CODE IN OTHER FILES=====
''' Execute the main view that is tree menu'''
@app.get("/softprop/tree")
def geto2(request:Request):
request.session['id']=xmother.newId(10) #Sets the session id
return getGeneralTreeViewCodeFH(menuDict=menuDict)
'''Responds to the event of a field '''
@app.get("/softprop/fieldEvent")
def getFieldEvent(request:Request):
return menu_params.getFieldEventDef(request)
''' More routes '''''
Подробнее здесь: https://stackoverflow.com/questions/793 ... n-fasthtml
Мобильная версия