I have to create a very generic endpoint for a user. The user may send JSON data or may upload a file to this endpoint.
There are multiple options on how to handle different input types, like Request or UploadFile
I thought about solving it like this (pseudo code):
from enum import Enum
class Multiple(Enum):
request: Request
file: UploadFile
@app.post("/")
async def root(Multiple):
if Multiple == request:
do xxx
else if Multiple == file:
do yyyy
else:
do zzz
Is there any way to make something like this work?