'How to pass JSON information from Flask to Typescript on browser
Variables can be passed between flask and javascript in the following way.
Python
return render_template(foo.html,input_from_python=data)
Javascript
let var_from_python = {{ input_from_python | tojson }};
However, if the notation for flask is included, Typescript cannot be compiled.
Typescript
const var_from_python = {{ input_from_python | tojson }};
Can you tell me how to do it better?
Solution 1:[1]
Your input from Python could be a json string and then on Typescript you should parse to object.
const var_from_python = json.parse("{{ python_input_json }}")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
