Skip to content
Advertisement

Tag: flask

Passing JSON data from Flask to JavaScript

I am trying to pass a JSON data from flask to JavaScript. The code I tried is from: Passing a JSON object from Flask to JavaScript The steps below are what I did : I first got my data from postgreSQL in Python I transformed the data format from DataFrame to JSON I modified @Ilya V. Schurov’s code And this

How to insert a JavaScript variable into Flask url_for() function?

I have following code in my Flask template: I want the link to render to: But I got this: How to make the js variable id in Flask url_for() function work? Thanks for your help! Answer Try this: url_for() will generate an URL like this: …/static/<filename>. If you use url_for(‘static’, filename=”), it generate an URL like: …/static/, so you can

Passing variables from Flask to JavaScript

I looked at similar forums but was not able to get any of the solutions to work. I am trying to pass variables from Flask to my JavaScript file. These values then will be used for PubNub from my JavaScript file. Here is part of my Python code: Here is part of my JavaScript code (app.js): this code works if

Advertisement