AnswerDotAI / fasthtml

The fastest way to create an HTML app
https://fastht.ml/
Apache License 2.0
5.34k stars 229 forks source link

[FEATURE] Any example or plan to integrate exist api service #536

Open thinker007 opened 13 hours ago

thinker007 commented 13 hours ago

If you'd like to discuss your feature idea first with the community (highly recommended!) please visit our Discord channel.

bring api to website not database。

using api build fasthtml website

muhis commented 5 hours ago

I fail to see why you can't achieve this with python code.

from fasthtml.common import *
import requests

app,rt = fast_app()

@rt('/')
def get():
response = requests.get("https://api.sampleapis.com/coffee/hot").  # << Make request
return Div(P(f'Hello World! {response.content}'), hx_get="/change")  # << Use API  response in user response

serve()