本文介绍了我想在我的网站上执行一个python脚本的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在使用django建立网站。现在,我想使用网站上的按钮从模板/视图执行python脚本。
I am currently making a website using django. Now I want to execute a python script from my template/view with a button on the website. It should be possible but to be honest I don't know how.
最好是一个例子。
非常感谢您提供帮助。
推荐答案
现在可以正常工作了,只是以为我会写答案:
Well got it working now and just thought I would write my answer:
view.py:
import script as gh
def get_hostname(request):
gh.main()
return HttpResponseRedirect('/')
urls.py:
...
url(r'^get_hostname/$', 'thinco.views.get_hostname'),
...
模板中的某个位置:
...
<form action="/get_hostname/" method="GET">
<input type="submit" value="Liste der Thin Clients laden">
</form>
...
这篇关于我想在我的网站上执行一个python脚本的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!