簡體   English   中英

python web.py Web服務多個參數查詢不起作用

[英]python web.py web service multiple parameters query not working

我使用web.py做了一個Web服務

安裝web.py cd webpy編輯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()

然后,我運行此Web服務../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我想知道為什么嗎? 為什么我無法打開鏈接並獲得哈希表?

謝謝!

您看到的[1] 1190不是來自您的web.py代碼(按編寫的要求正確)。 它來自您的外殼程序,以響應您的“鏈接”命令。

外殼程序看到了未轉義的&符,並將您的links命令放在后台[1]以進程ID 1190

用引號引起來的URL,例如:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM