completed renaming to Kaya
This commit is contained in:
+15
-4
@@ -1,7 +1,7 @@
|
||||
from kaya import BugisApp, HttpContext, HttpMethod
|
||||
from kaya import KayaApp, HttpContext, HttpMethod, WebSocket
|
||||
from typing import List
|
||||
|
||||
class Hello(BugisApp):
|
||||
class Hello(KayaApp):
|
||||
pass
|
||||
|
||||
# async def handle_request(self, ctx: HttpContext) -> None:
|
||||
@@ -10,7 +10,7 @@ class Hello(BugisApp):
|
||||
# await ctx.send_str(200, 'Hello World')
|
||||
|
||||
|
||||
app = BugisApp()
|
||||
app = KayaApp()
|
||||
|
||||
|
||||
@app.GET('/hello')
|
||||
@@ -42,4 +42,15 @@ async def hello_bob_marley(ctx: HttpContext) -> None:
|
||||
async def handle_put_request(ctx: HttpContext, _: List[str]) -> None:
|
||||
async for chunk in ctx.request_body:
|
||||
print(chunk.decode())
|
||||
await ctx.send_str(200, 'Message received')
|
||||
await ctx.send_str(200, 'Message received')
|
||||
|
||||
@app.websocket('/echo')
|
||||
async def echo(ws: WebSocket) -> None:
|
||||
await ws.accept()
|
||||
async for msg in ws:
|
||||
if msg.kind == 'text':
|
||||
await ws.send_text(f"echo: {msg.data}")
|
||||
elif msg.kind == 'binary':
|
||||
data = msg.data
|
||||
assert isinstance(data, bytes)
|
||||
await ws.send_bytes(data)
|
||||
Reference in New Issue
Block a user