from fastapi import HTTPException
from fastui import FastUI, AnyComponent, components as c
from fastui.components.display import DisplayMode, DisplayLookup
from fastui.events import GoToEvent, BackEvent
from my_app import router, fetch_users
@router.get("/users", response_model=FastUI, response_model_exclude_none=True)asyncdefusers_table() -> list[AnyComponent]:
"""Show a table of users"""
users = await fetch_users()
return [
c.Page( # Page provides a basic container for components# Add your components here
)
]
import asyncio
from arq import create_pool
from arq.connections import RedisSettings
from httpx import AsyncClient
asyncdefmain():
redis = await create_pool(RedisSettings())
for url in ('https://facebook.com', 'https://microsoft.com', 'https://github.com'):
await redis.enqueue_job('download_content', url)
asyncdefdownload_content(ctx, url):
asyncwith AsyncClient() as client:
response = await client.get(url)
return response.text