tarp20
tarp20

Reputation: 695

TypeError: post() missing 1 required positional argument: 'path' in FastApi?

Where is mistake in FastApi?

Error is:

@video_router.post('/info')
TypeError: post() missing 1 required positional argument: 'path'

api.py

from fastapi import APIRouter
video_router = APIRouter
@video_router.post('/info')
async def info_set(info: UploadVideo):
    return info

main.py:

from fastapi import FastAPI
from api import video_router
app = FastAPI()
app.include_router(video_router)

Upvotes: 4

Views: 12180

Answers (1)

user459872
user459872

Reputation: 24562

The issue is here.

video_router = APIRouter

video_router must be an instance of APIRouter class not the reference to the class itself. So change it to

video_router = APIRouter()

Upvotes: 10

Related Questions