Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

293
Vistas
ModuleNotFoundError: No module named 'fastapi.responses'

I am trying to use HTMLResponse from FastAPI, as described in the documentation. I'm on version 0.70. I keep getting the following error:

ModuleNotFoundError: No module named 'fastapi.responses'

My code is shown below:

from fastapi import FastAPI
from fastapi.responses import HTMLResponse
import os
from os import curdir, environ as env

app = FastAPI()

name='fred'
@app.get("/getName")
def returnName():
html_content = """
    <html>
        <head>
            <title>Some HTML in here</title>
        </head>
        <body>
            <h1>Name is {{name}}</h1>
        </body>
    </html>
    """
    return HTMLResponse(content=html_content, status_code=200)

Any ideas?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Since FastAPI is built on top of Starlette, try this:

from starlette.responses import HTMLResponse
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda