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

206
Visualizações
How to open a json file in javascript in a python flask enviroment

I'm creating a simple webapp. I have a json file, with some datas I need to be processed using javascript ( using javascript and not python to avoid the post request and the page reloading). I have both the js file and the json file in the "/static" directory of the Flask enviroment. Now, I would like to know how to import the json file. I tried using fetch this way:

fetch("test.json")
  .then(response => response.json())
  .then(json => console.log(json));

But it failed. I tried to read the file via python and the pass it in javascript with the following code:

with open("file.json", "r") as data:
    print(data)

But it said me that that file wasn't found. I also read some other sackoverflow answer, and read Json documentation, without finding anything. Some ideas? Thanks

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It’s easy if you know what separation of front-end and backend and http protocol.

Your JavaScript code maybe need some change ... ,like this fetch("/static/test.json") .then(response => response.json()) .then(json => console.log(json));

Import json on the server is not appropriate

about 4 years ago · Juan Pablo Isaza 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