【问题标题】:python web.py web service multiple parameters query not workingpython web.py web服务多参数查询不起作用
【发布时间】:2015-03-23 04:24:43
【问题描述】:

我使用 web.py 做了一个网络服务

安装 web.py 光盘网络 编辑 python 网络服务。

#!/usr/bin/env python

urls = ('/title_matching2','title_matching2')
app = web.application(urls,globals())




class title_matching2:
    def __init__(self):
        self.hello = "hello world"

    def GET(self):
       getInput = web.input(name="World")

       processing the data, return the hash table, I wanted 




           return gg

       if __name__ == "__main__":
        app.run()

然后我运行这个网络服务,./some.py,然后调用:

links http://localhost:8080/title_matching2?title=diehard

它返回一个哈希表,这是我想要的

但如果我使用多个参数运行 web 服务, 代码如下:

    usr/bin/env python

    urls = ('/title_matching4','title_matching4')
    app = web.application(urls,globals())




    class title_matching4:
        def __init__(self):
            self.hello = "hello world"

        def GET(self):
           getInput = web.input(title="World",prod="type")

       title1=str(getInput.title)
       prod1=str(getInput.prod)
       processing the data, return the hash table I wanted. 

       return qq

if __name__ == "__main__":
        app.run()

然后运行
./rest9.py 然后我使用链接打开了一个链接 http://localhost:8080/title_matching4?title=diehard&prod=feature 没有返回哈希表,虽然我想返回一个哈希表 屏幕上会出现如下内容: [1] 1190 我想知道为什么? 为什么我无法打开链接并获取哈希表?

谢谢!

【问题讨论】:

  • 您能否将代码简化为显示问题的最小示例?
  • 谢谢。刚刚做到了!任何cmets,让我知道。谢谢!

标签: python web.py


【解决方案1】:

您看到的[1] 1190 不是来自您的 web.py 代码(编写时正确)。它来自您的 shell,以响应您的“链接”命令。

Shell 看到未转义的 & 符号 (&) 并将您的 links 命令在后台执行 [1],进程 ID 为 1190

用引号将 URL 括起来,例如:

links 'http://localhost:8080/title_matching4?title=diehard&prod=feature'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多