python web.py web service multiple parameters query not working

半城伤御伤魂 提交于 2019-12-13 07:42:55

问题


I did a web service using web.py

install web.py cd webpy edit python web service.

#!/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()

Then I run this web service , ./some.py, and then call:

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

And it returns a hash table it is what I want

But if I run run the web service using multiple parameters, The code is as follow:

    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()

and then run
./rest9.py And then I opened a link using links http://localhost:8080/title_matching4?title=diehard&prod=feature no hash table returned, although I want to have a hash table returned Something like below appears on the screening: [1] 1190 I am wondering why? Why I can not open a link and get a hash table?

Thank you!


回答1:


The [1] 1190 you're seeing isn't from you web.py code (which is correct as written). It is from your shell in response to your 'links' command.

The shell is seeing the unescaped ampersand (&) and putting your links command to execute in the background [1] with process id 1190.

Surround the URL with quotes, for example:

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


来源:https://stackoverflow.com/questions/29203256/python-web-py-web-service-multiple-parameters-query-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!