简体   繁体   English

Flask - 将 Javascript 变量发送到 Python

[英]Flask - Send Javascript Variable to Python

I'm looking for a simple Flask example that demonstrates pressing a button in an HTML page that sends a Javascript string variable to Flask in Python and then prints that string to the terminal where the app is running. I'm looking for a simple Flask example that demonstrates pressing a button in an HTML page that sends a Javascript string variable to Flask in Python and then prints that string to the terminal where the app is running.

Flask RESTful API. Flask RESTful API。 It's not that easy as you might think.这并不像你想象的那么容易。 You have to set up basic Flask RESTful API for this and make post requests from the JS code, passing the variable as a parameter.您必须为此设置基本的 Flask RESTful API 并从 JS 代码发出 post 请求,将变量作为参数传递。 For the Flask side you will be good off with this Flask RESTful documentation And for the frontend you want to use something like Axios or similar things对于 Flask 方面,你会很好地使用这个Flask RESTful 文档对于前端,你想使用类似 Axios 或类似的东西

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM