Skip to content
Advertisement

pass variable from JavaScript to Python using Flask [closed]

It’s an error I’ve been stuck on for a while.

JavaScript

How would I pass this to python with Flask without using any complicated GET/POST requests? My end goal is to print the statement in the python console.

JavaScript

Pseudocode

Advertisement

Answer

Ok, there is a lot to learn, but an example made everything better to understand:

app.py

JavaScript

templates/index.html

JavaScript

This simple code will print the longitute value when you click in the button only on console, but also triggers a post request from Javascript that will do the same automatically every time you access the page.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement