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

288
Views
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 answers
Answer question

0

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

from starlette.responses import HTMLResponse
over 4 years ago · Santiago Trujillo Report
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!