pythonanywhere-web2py 메시징 예제에 따라 웹 소켓을 사용하여 메시지를 전송하는 방법은 무엇입니까?

evan54

그래서 web2py와 pythonanywhere로 웹 소켓을 테스트하는 앱을 만들었고 로컬에서 작동하도록했지만 pythonanywhere에 업로드 할 때 작동하지 않습니다. 그 이유는 내가 localhost (127.0.0.1)로 물건을 보내고 있지만 업로드 할 때 물건을 어디로 보내야하는지 (듣고) 알지 못하기 때문이라고 생각합니다.

debug.py 스크립트는 다음과 같습니다.

def listen():

    script=SCRIPT('''
         jQuery(document).ready(function(){
           var callback=function(e){$("#test_div").html(e.data)};
    if(!web2py_websocket('ws://127.0.0.1:8880/realtime/mygroup',callback))
             alert("html5 websocket not supported by your browser, try Google Chrome");
         });
     ''')
     d = ''
     return { 'd':d , 'script':script }

def send():
    form=LOAD('debug','ajax_form',ajax=True)
    return { 'form':form }

def ajax_form():
    form=SQLFORM.factory(Field('message'))
    if form.accepts(request,session):
        import websocket_messaging
        reload( websocket_messaging )
        websocket_messaging.websocket_send( 'http://127.0.0.1:8880' , form.vars.message , 'mykey' , 'mygroup' )                                                                    
    return form

listen.html

{{extend 'layout.html'}}

<div id="test_div">
    {{=d}}
</div>

{{=script}}

send.html

{{extend 'layout.html'}}

{{=form}}

몇 가지 추가 사항 :

  • 나는 당 토네이도 서버 시작 pythonanywhere에서 bash는 터미널에서.

    python websocket_messaging.py -p 8880 -k mykey
    
  • 나는 pythonanywhere에 무료 계정을 가지고 있으며 비용을 지불하기 전에 이것을 테스트하고 싶습니다.

  • pythonanywhere에서 내가 원하는 것을 할 수 없다는 것을 의미하는 것처럼 보이는 이것을 찾았 습니까?

자일스 토마스

여기 PythonAnywhere dev-불행히도 WebSocket은 현재 우리 서비스에서 작동하지 않습니다 :-(

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관