Python: Google App Engine , JavaScript Channel API

2019-03-30 20:19发布

Hi I am quite new to java script and i am looking a working example to call back ends using java script channel API . I do not have any idea about channel API . Can anyone provide me a working example

2条回答
神经病院院长
2楼-- · 2019-03-30 20:38

If you're asking how to get a message from the backend to a javascript client: you can't send messages from a backend server to a channel created on a frontend server. This is because the app version number is included in the channel token, and backends have a different app version than frontends. You could, however, implement a servlet in your backend that calls createChannel and returns it to your frontend for inclusion in javascript that your frontend renders.

If you're trying to send a message to a backend from your javascript code, you won't be able to use XmlHttpRequest directly because of the same-origin policy (this assumes your clients are rendered from a non-backend instance). You could get around this using JSONP, or by routing XHR requests from your frontend to your backend in a frontend servlet.

查看更多
我想做一个坏孩纸
3楼-- · 2019-03-30 20:39

Did you see the docs? Java / Python

查看更多
登录 后发表回答