Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

299
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda