Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

298
Views
How to use FastAPI to fill HTML page from HTTP request

Im trying to fill a website (chatbot widget) using FastAPI. I want the page to show me a first message automatically, then I type something, that text is sent via POST request to Rasa server. Then it should display the response back in frontend.

This is my index.html:

<html>
<div id="rasa-chat-widget" data-websocket-url="http://localhost:5005"></div>
<script src="https://unpkg.com/@rasahq/rasa-chat" type="application/javascript"></script>
</html>

This is some of my FastAPI code

@app.get("/", response_class=HTMLResponse)
def index():
    path = "/path"
    return HTMLResponse(content=pathlib.Path(path).read_text(), status_code=200)

@app.post("/parse")
def post_attempt(text: Text):
    body = {"text": text.text,"message_id": str(uuid.uuid4())}
    headers = {'content-type': 'application/json'}
    url = "http://localhost:5005/webhooks/rest/webhook"
    return requests.post(url, data=json.dumps(body), headers=headers)

However I get no reply from Rasa server on the frontend, I just see the chat widget when opening webpage and am able to type, but Rasa is not returning a response and showing on html page. What am I missing? thanks

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!