[Python] Why do I get "GET / HTTP/1.1 404 Not Found" with FastAPI server?

Discussão em 'Python' iniciado por Stack, Abril 15, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to create a token with FastAPI:

    > import json
    > import os
    > import aiohttp
    > import asyncio
    > from fastapi import FastAPI
    > from fastapi import APIRouter, Request
    > from fastapi.responses import JSONResponse
    >
    > token = APIRouter(prefix="/management/api", tags=["API Apl token"])
    >
    > app=FastAPI()
    > app.include_router(token)


    and many methods after...

    I got this

    > uvicorn peg:token --reload
    > INFO: Will watch for changes in these directories: ['C:\\Users\\Ejbc25\\fastapi']
    > INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
    > INFO: Started reloader process [2232] using StatReload
    > INFO: Started server process [20632]
    > INFO: Waiting for application startup.
    > INFO: Application startup complete.
    > INFO: 127.0.0.1:51183 - "GET / HTTP/1.1" 404 Not Found
    > INFO: 127.0.0.1:51183 - "GET / HTTP/1.1" 404 Not Found


    How to fix this problem?

    I expected that http://127.0.0.1:8000/token would return token but shows


    Not Found
    ​

    Continue reading...

Compartilhe esta Página