Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

344
Visualizações
Retrieve form data with python

I am new to web communication. I use ubuntu and try to learn fastapi. Let's say I post a file using curl. Seems to be common opinion that this is the best way to do it:

curl -F "file=@image1.jpg" http://127.0.0.1:8000/image -v

Now, on the server side I want to retrieve the image and add 1 to every pixel-value and then return it. But I have now idea how I "catch" the image from curl, how do I do that? Right now, I only have the the dummy function below which does not do anything intelligent:

@app.post("/image")
async def post_test():
    print("I don't know how to catch the image :( ")
    return {"You sent an image..."}

Please help with how I should write the post_test function! (Flask would work as well.)

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You can check the full answer from my SO answer for a similar question (How to send file to fastapi endpoint using postman)

Basically, you would have to change your code to

from fastapi import FastAPI, UploadFile, File


app = FastAPI()


@app.post("/file/")
async def create_upload_file(file: UploadFile = File(...)):
    # Access your file object via file.file,
    # and perform all the necessary transformations
    # Return the filename, but you may return the file itself
    return {"filename": file.filename}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda