烧瓶插座
适用于Flask应用程序的优雅WebSocket。
route装饰器的简单用法:
from flask import Flask
from flask_sockets import Sockets
app = Flask ( __name__ )
sockets = Sockets ( app )
@ sockets . route ( '/echo' )
def echo_socket ( ws ):
while not ws . closed :
message = ws . receive ()
ws . send ( message )
@ app . route ( '/' )
def hello ():
return 'Hello World!'
if __name__ == "__main__" :
fro
2021-09-03 10:21:23
5KB
Python
1