[英]flask service on heroku
I'm trying to figure out how to run a web service on heroku using flask and JSONRPC. 我试图弄清楚如何使用flask和JSONRPC在heroku上运行Web服务。 I would like to get to a point where, from my desktop I can do:
我想说的是,在我的桌面上我可以做到:
from flask_jsonrpc.proxy import ServiceProxy
service = ServiceProxy('http://<myapp>.heroku.com/api')
result = service.App.index()
print result
looking at heroku logs I can see : 查看heroku日志,我可以看到:
2014-07-05T13:18:42.910030+00:00 app[web.1]: 2014-07-05 13:18:42 [2] [INFO] Listening at: http://0.0.0.0:21040 (2)
and trying using that port with : 并尝试通过使用该端口:
service = ServiceProxy('http://<myapp>.heroku.com:21020/api')
still doesn't make it work (it seems hanging) 仍然不能正常工作(似乎挂起了)
But when I run this through foreman, though, I can happy access it and seems working fine. 但是,当我通过领班进行操作时,我可以很开心地访问它,并且看起来工作正常。
but when I try with the deployed application I get: 但是当我尝试部署的应用程序时,我得到:
ValueError: No JSON object could be decoded
This is the application (not much I know , but is just to see how heroku works) 这是应用程序(我了解不多,但只是看heroku是如何工作的)
import os
from flask import Flask
from flask_jsonrpc import JSONRPC
app = Flask(__name__)
jsonrpc = JSONRPC(app, '/api', enable_web_browsable_api=True)
@jsonrpc.method('App.index')
def index():
return u'Welcome to Flask JSON-RPC'
if __name__ == '__main__':
port = int(os.environ.get("PORT", 5000))
app.run(host='0.0.0.0', debug=True, port=port)
this is the content of my Procfile: 这是我的Procfile的内容:
web: gunicorn run:app -p $PORT
Am I missing something obvious here ? 我在这里错过明显的东西吗? Cheers.
干杯。
L. L.
pS 压力
accessing http://.heroku.com/api/browse from within the through foreman and the deployed app, it seems working fine. 从领班和已部署的应用程序内部访问http://.heroku.com/api/browse,看来工作正常。
[edit] [编辑]
solved : 解决了 :
yes I was missing something.... looking better a the log I noticed the host which was : 是的,我丢失了一些东西。...看起来更好,我注意到主机是:
host=<myapp>.herokuapp.com
instead of .heroku.com 而不是.heroku.com
Changing the address to the correct one, it all seems working fine. 将地址更改为正确的地址,似乎一切正常。 http://.herokuapp.com/api
http://.herokuapp.com/api
All sorted , see original post. 全部排序,请参阅原始帖子。 Sorry for the noise.
对不起,噪音。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.