I have a fast API server I am building, but the images and CSS files from the template I grabbed are refusing to show up.
Fast API:
from fastapi import FastAPI, status, Response
import asyncio
from fastapi.responses import HTMLResponse, StreamingResponse
from fastapi.requests import Request
from fastapi.templating import Jinja2Templates
from fastapi.staticfiles import StaticFiles
app = FastAPI()
#app.mount("/static",StaticFiles(directory="static",name = "static")
templates = Jinja2Templates(directory="templates")
@app.get("/index", response_class=HTMLResponse)
async def home(request: Request):
return templates.TemplateResponse("index.html", {"request": request})
The folders are set up as follows:
Server.py
Templates
- index.html
- css
- template.css
- img
- img1
- img2
There is a templates folder which hosts all of my web files the HTML is in there and inside also are folders for CSS and IMG. I run the code and receive an error that says: ""GET /css/tooplate-vertex.css HTTP/1.1" 404 Not Found". Unsure where this is occurring and I am new to FastAPI, but if this isn't clear let me know.
Templatesandtemplatesare different folders.