开发者

web.py - Is it possible to pass parameters from template to the script?

Is it possible to pass parameters from template back to the script ?

In example I have a page add.html with a few input fields like Name, Last name.

<input type="text" name="name" size="50" />
<input type="text" name="last_name" size="50" />

In addition, 开发者_开发技巧I have secret key (just an example, remember? :)):

$ secret_key = random.randint(0,10)

Can I pass secret_key and get it via web.input inside script?

Something like that maybe?:

main.py:

def add(self):
    def POST(self):
        post_sent = web.input()
        secret_key = post_sent['secret_key'] # extracted from template


You can add a hidden input.

<input type="hidden" name="secret_key" value="$random.randint(0,10)" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜