Reputation: 97
I am working on a project that involves users signing up and accessing a dashboard. For this I've written an API, but I don't know how to serve them both on the same domain and also use the API to change dashboard accordingly. the api is written in python using FastAPI and the site is currently written in vanilla JS (for prototyping). Is this possible? If so, how do I go about doing it?
Thanks in advance!
Upvotes: 0
Views: 1010
Reputation: 4456
If your website consists of only static pages, you can store them in a folder and tell Fastapi to serve static files from that folder.
Here's the example taken from the docs
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
app = FastAPI()
app.mount("/static", StaticFiles(directory="static"), name="static")
https://fastapi.tiangolo.com/tutorial/static-files/?h=stat
Upvotes: 2