Wie füge ich sowohl Datei als auch JSON -Body in einer Fastapi -Post -Anfrage hinzu?Python

Python-Programme
Guest
 Wie füge ich sowohl Datei als auch JSON -Body in einer Fastapi -Post -Anfrage hinzu?

Post by Guest »

Insbesondere möchte ich, dass das folgende Beispiel funktioniert: < /p>

Code: Select all

from typing import List
from pydantic import BaseModel
from fastapi import FastAPI, UploadFile, File

app = FastAPI()

class DataConfiguration(BaseModel):
textColumnNames: List[str]
idColumn: str

@app.post("/data")
async def data(dataConfiguration: DataConfiguration,
csvFile: UploadFile = File(...)):
# read requested id and text columns from csvFile
pass
Wenn dies nicht die richtige Möglichkeit für eine Post Anforderung ist, teilen Sie mir bitte mit, wie Sie die erforderlichen Spalten aus einer hochgeladenen CSV -Datei in Fastapi auswählen.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post