这是我编写的 Cherrypy 中的服务器,我想添加查询字符串。
但是当我使用重定向站点时,它似乎不适用于localhost:8080/index?foo=1&foo=2
为什么?
我的项目
import cherrypy
import urllib
#import requests
class Root(object):
@cherrypy.expose
def index(self):
jsondict = [('foo', '1'), ('foo', '2')]
p = urllib.urlencode(jsondict)
#url = urllib.urlopen("http://localhost:8080?%s" % params)
#urlVar = 1
#urlVar2 = 2
#requests.get("localhost:8080/?", params =p)
raise cherrypy.HTTPRedirect("localhost:8080/index?" + p)
cherrypy.config.update({
'server.socketPort': 8080
})
cherrypy.quickstart(Root())
但我想在网站启动时在 Url 上添加变量