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

445
Visualizações
Bad: FastApi response problems

i create api using fastapi framework and i have deployed on heroku, the main function of this api is i have to send (post method) element as query parameter every 10s and i create path to show all elements sent but i facing problem when i refresh page i didn't get all element sent for example if i send [1, 2, 3, 4, 5, 6, 7, 8, 9] sometimes i get [1, 3, 4, 5, 7, 9] and sometimes i get [2, 6, 8], but in local i have api run perfectly.

from fastapi import FastAPI

app = FastAPI()

hr = []


@app.get("/")
async def api_status():
    return {"message": "api running"}


@app.get("/hr")
async def show_hr_values():
    if hr:
        return hr
    return {"message": "hr empty"}


@app.post("/hr")
async def add_hr_value(hr_value: int):
    hr.append(hr_value)
    return {"message": f"hr = {hr_value} added"}
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Heroku will not run your application as just one process. Since you're keeping this data in memory, it will only be updated and kept in that process that receives your request.

Use a database or KV store to store your data instead, so that it's stored in a centralized location that all processes can talk to. Heroku supports managed postgres and redis that you can use for either of these use cases.

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