Flask

【自取】最近整理的,有需要可以领取学习:

It sounds like you want to use this web application as a remote control for your robot, and a core issue is that you won’t want a page reload every time you perform an action, in which case, the last link you posted answers your problem.

I think you may be misunderstanding a few things about Flask. For one, you can’t nest multiple functions in a single route. You’re not making a set of functions available for a particular route, you’re defining the one specific thing the server will do when that route is called.

With that in mind, you would be able to solve your problem with a page reload by changing your app.py to look more like this:

Then in your html, use this:

…To execute your moving forward code. And include this:

… where you want the moving forward message to appear on your template.

This will cause your page to reload, which is inevitable without using AJAX and Javascript.

Original: https://www.cnblogs.com/weifeng1463/p/15865591.html
Author: Calling python function on button OnClick event
Title: Flask

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/6382/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

发表回复

登录后才能评论
免费咨询
免费咨询
扫码关注
扫码关注
联系站长

站长Johngo!

大数据和算法重度研究者!

持续产出大数据、算法、LeetCode干货,以及业界好资源!

2022012703491714

微信来撩,免费咨询:xiaozhu_tec

分享本页
返回顶部