大家好。我用了python 的 web.py做了一个 web service
install web.py
cd webpy
编辑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()
然后 run 这个 web service , ./some.py, 再call:
links http://localhost:8080/title_matching2?title=diehard
会返回一个hash table. 正是我想要的。
但是如果run multiple parameters 的话:
代码如下:
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()
然后再run ./rest9.py
再打开一个link:
links http://localhost:8080/title_matching4?title=diehard&prod=feature
就没有hash table 返回。虽然我想返回hash table.
只是出现如下东西在screen 上:
ubuntu@ip-10-0-0-126:~$ links http://localhost:8080/title_matching4?title=diehard&prod=feature
[1] 1190
请问这是为什么?
为什么不能打开一个连接,并有hash table 返回?
多谢!