Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

205
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda