Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

208
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!