-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
25 lines (19 loc) · 859 Bytes
/
main.py
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
# Copyright 2024 Hasan Sezer Taşan <[email protected]>
# Copyright (C) 2024 <[email protected]>
from __future__ import annotations
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from fastui import AnyComponent, FastUI, prebuilt_html
from fastui import components as c
app = FastAPI()
@app.get("/api/", response_model=FastUI, response_model_exclude_none=True)
def page() -> list[AnyComponent]:
return [
# Page component is a container for other components
# It can have multiple components as children
c.Page(components=[c.Heading(text="I'm a heading in a page")]),
]
@app.get("/{path:path}")
def root() -> HTMLResponse:
"""Simple HTML page which serves the React app, comes last as it matches all paths."""
return HTMLResponse(prebuilt_html(title="FastUI Simple Layout"))