问题
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