websockets Documentation
Release 9.0coroutine-based API. Here’s how a client sends and receives messages: #!/usr/bin/env python import asyncio import websockets async def hello(): uri = "ws://localhost:8765" async with websockets.connect(uri) here’s an echo server: #!/usr/bin/env python import asyncio import websockets async def echo(websocket, path): async for message in websocket: await websocket.send(message) start_server = websockets example. It reads a name from the client, sends a greeting, and closes the connection. #!/usr/bin/env python # WS server example import asyncio import websockets async def hello(websocket, path): name0 码力 | 81 页 | 352.88 KB | 1 年前3
Tornado 6.5 Documentationwrite("Hello, world") def make_app(): return tornado.web.Application([ (r"/", MainHandler), ]) async def main(): app = make_app() app.listen(8888) await asyncio.Event().wait() if __name__ == "__main__": RequestHandler which is subclassed to create web applications, and various supporting classes). • Client- and server-side implementions of HTTP (HTTPServer and AsyncHTTPClient). • An asynchronous networking function: from tornado.httpclient import HTTPClient def synchronous_fetch(url): http_client = HTTPClient() response = http_client.fetch(url) return response.body And here is the same function rewritten asynchronously0 码力 | 272 页 | 1.12 MB | 3 月前3
Tornado 6.4 Documentation
write("Hello, world") def make_app(): return tornado.web.Application([ (r"/", MainHandler), ]) async def main(): app = make_app() app.listen(8888) await asyncio.Event().wait() if __name__ == "__main__": RequestHandler which is subclassed to create web applications, and various supporting classes). • Client- and server-side implementions of HTTP (HTTPServer and AsyncHTTPClient). • An asynchronous networking function: from tornado.httpclient import HTTPClient def synchronous_fetch(url): http_client = HTTPClient() response = http_client.fetch(url) return response.body And here is the same function rewritten asynchronously0 码力 | 268 页 | 1.09 MB | 1 年前3
Tornado 6.4 Documentation
write("Hello, world") def make_app(): return tornado.web.Application([ (r"/", MainHandler), ]) async def main(): app = make_app() app.listen(8888) await asyncio.Event().wait() if __name__ == "__main__": RequestHandler which is subclassed to create web applications, and various supporting classes). • Client- and server-side implementions of HTTP (HTTPServer and AsyncHTTPClient). • An asynchronous networking function: from tornado.httpclient import HTTPClient def synchronous_fetch(url): http_client = HTTPClient() response = http_client.fetch(url) return response.body And here is the same function rewritten asynchronously0 码力 | 268 页 | 1.09 MB | 1 年前3
Tornado 6.4 Documentation
write("Hello, world") def make_app(): return tornado.web.Application([ (r"/", MainHandler), ]) async def main(): app = make_app() app.listen(8888) await asyncio.Event().wait() if __name__ == "__main__": RequestHandler which is subclassed to create web applications, and various supporting classes). • Client- and server-side implementions of HTTP (HTTPServer and AsyncHTTPClient). • An asynchronous networking function: from tornado.httpclient import HTTPClient def synchronous_fetch(url): http_client = HTTPClient() response = http_client.fetch(url) return response.body And here is the same function rewritten asynchronously0 码力 | 268 页 | 1.09 MB | 1 年前3
Tornado 6.3 Documentation
write("Hello, world") def make_app(): return tornado.web.Application([ (r"/", MainHandler), ]) async def main(): app = make_app() app.listen(8888) await asyncio.Event().wait() if __name__ == "__main__": RequestHandler which is subclassed to create web applications, and various supporting classes). • Client- and server-side implementions of HTTP (HTTPServer and AsyncHTTPClient). • An asynchronous networking function: from tornado.httpclient import HTTPClient def synchronous_fetch(url): http_client = HTTPClient() response = http_client.fetch(url) return response.body And here is the same function rewritten asynchronously0 码力 | 264 页 | 1.06 MB | 1 年前3
Tornado 6.2 Documentation
write("Hello, world") def make_app(): return tornado.web.Application([ (r"/", MainHandler), ]) async def main(): app = make_app() app.listen(8888) await asyncio.Event().wait() if __name__ == "__main__": RequestHandler which is subclassed to create web applications, and various supporting classes). • Client- and server-side implementions of HTTP (HTTPServer and AsyncHTTPClient). • An asynchronous networking function: from tornado.httpclient import HTTPClient def synchronous_fetch(url): http_client = HTTPClient() response = http_client.fetch(url) return response.body And here is the same function rewritten asynchronously0 码力 | 260 页 | 1.06 MB | 1 年前3
Tornado 5.1 Documentation
RequestHandler which is subclassed to create web applications, and various supporting classes). • Client- and server-side implementions of HTTP (HTTPServer and AsyncHTTPClient). • An asynchronous networking than chaining callbacks. This is similar to the native coroutine feature introduced in Python 3.5 (async def). Native coroutines are recommended in place of the tornado.gen module when available. The Tornado function: from tornado.httpclient import HTTPClient def synchronous_fetch(url): http_client = HTTPClient() response = http_client.fetch(url) return response.body And here is the same function rewritten asynchronously0 码力 | 243 页 | 895.80 KB | 1 年前3
Tornado 6.1 Documentation
HTTP server tornado.httpclient — Asynchronous HTTP client tornado.httputil — Manipulate HTTP headers and URLs tornado.http1connection – HTTP/1.x client/server implementation Asynchronous networking tornado (including RequestHandler which is subclassed to create web applications, and various supporting classes). Client- and server-side implementions of HTTP (HTTPServer and AsyncHTTPClient). An asynchronous networking than chaining callbacks. This is similar to the native coroutine feature introduced in Python 3.5 (async def). Native coroutines are recommended in place of the tornado.gen module when available. The Tornado0 码力 | 931 页 | 708.03 KB | 1 年前3
Tornado 6.1 Documentation
RequestHandler which is subclassed to create web applications, and various supporting classes). • Client- and server-side implementions of HTTP (HTTPServer and AsyncHTTPClient). • An asynchronous networking than chaining callbacks. This is similar to the native coroutine feature introduced in Python 3.5 (async def). Native coroutines are recommended in place of the tornado.gen module when available. The Tornado function: from tornado.httpclient import HTTPClient def synchronous_fetch(url): http_client = HTTPClient() response = http_client.fetch(url) return response.body And here is the same function rewritten asynchronously0 码力 | 245 页 | 904.24 KB | 1 年前3
共 495 条
- 1
- 2
- 3
- 4
- 5
- 6
- 50













