boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Seattle版 - 如何用python web.py web service 做 multiple parameters 的que (转载)
相关主题
支持Trump和共和党是两码事
请问向量势怎么求???Vector Potential???
有没有打冰球的小朋友
小小 youtube -> Mitbbs 转换。
黑灯瞎火奔
也来夸一夸bing地图:加国落基山游记
请推荐西雅图地区电台
Bellevue这边换护照的注册开始了
MSN的link scanner真恶心
Google 跟同桌 Bing 说:同学,别再抄袭俺的搜索结果了嘛
相关话题的讨论汇总
话题: title话题: __话题: matching4话题: python话题: hash
进入Seattle版参与讨论
1 (共1页)
t***q
发帖数: 418
1
【 以下文字转载自 Programming 讨论区 】
发信人: treeq (treeq), 信区: Programming
标 题: 如何用python web.py web service 做 multiple parameters 的query
发信站: BBS 未名空间站 (Sun Mar 22 23:14:33 2015, 美东)
大家好。我的那个web service 做成了。用了python 的 web.py.
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 返回?
多谢!
t***q
发帖数: 418
2
大家好。
我后来又找到一个可以做query的package 叫flask.也是在python 里。
用它写了一个multiple parameters 的query,差不过如下:
http://stackoverflow.com/questions/15182696/multiple-parameters
还是用links 打开一个网页
links http://127.0.0.1:5000/api?name=XXX&prod=XXX
没有回应。只是出现一个随机数,在screen上。
但是用curl就能返回想要的东西:
curl -XGET 'http://127.0.0.1:5000/api?name=XXX&prod=XXX'
而且用curl -XGET作用在以前用web.py的东西上也能得到想要的。但是,只是在screen
上显示一堆东西。并不是打开网页。
请问这是为什么?就是说用curl,不管怎样都能返回想要的东西,用links 不管怎样都
不能返回想要的东西。这样一来只要curl能跑出来东西,是不是就成了?
多谢!
1 (共1页)
进入Seattle版参与讨论
相关主题
Google 跟同桌 Bing 说:同学,别再抄袭俺的搜索结果了嘛
微软谷歌口水战再升级 称抄袭指控是“侮辱”
如何证明Bing参考了Google的搜索结果
越是有钱越是一刻不肯放松啊
Facebook邮件地址钓鱼欺诈正在传播
wujin网友的帖子大家要慎重对待。
求 CenturyLink 用户帮忙测试府上的连线速度
西版达人秀
hotmail is down?
如何改变自己上帖的 IP 地址?
相关话题的讨论汇总
话题: title话题: __话题: matching4话题: python话题: hash