when I use below source
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
app = FastAPI()
answer = "APPLE"
@app.get("/answer")
def get_answer():
return answer
app.mount("/static", StaticFiles(directory="static", html=True), name="static")
then I can get API response "APPLE" but in "/" path, my html page is not found (404 error) So when I use below source
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
app = FastAPI()
answer = "APPLE"
@app.get("/answer")
def get_answer():
return answer
app.mount("/", StaticFiles(directory="static", html=True), name="static")
then I can get my page but not api response.
my path is like this enter image description here
- port change
- port shut down and reload
- move js file to static folder