让CherryPy“提交”按钮启动外部网页

2024-09-29 00:14:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个非常简单的cherrypyweb表单,它接受用户提交的字符串。我想要的是获取这个字符串,从中构建一个URL,然后启动一个外部web页面。我有了它,所以URL就建立了——我只是现在不想在提交时打开这个URL。思想?在

from cherrypy import expose
from jira.client import JIRA

class Redirector:
    @expose
    def index(self):
        return '''<html>
                  <body>
                  <form action="redirect">
                      <input name="url" />
                      <input type="submit" />
                  </form>
                  </body>
                  </html>'''

    @expose
    def redirect(self, url):
        return url


if __name__ == "__main__":
    from cherrypy import quickstart
    quickstart(Redirector())

Tags: 字符串fromimportselfformurlreturndef