tmp
This commit is contained in:
+39
-8
@@ -1,12 +1,13 @@
|
||||
from bugis.core import BugisApp, HttpContext
|
||||
|
||||
from bugis.core import BugisApp, HttpContext, HttpMethod
|
||||
from typing import List
|
||||
|
||||
class Hello(BugisApp):
|
||||
pass
|
||||
|
||||
async def handle_request(self, ctx: HttpContext) -> None:
|
||||
async for chunk in ctx.request_body:
|
||||
print(chunk)
|
||||
await ctx.send_str(200, 'Hello World')
|
||||
# async def handle_request(self, ctx: HttpContext) -> None:
|
||||
# async for chunk in ctx.request_body:
|
||||
# print(chunk.decode())
|
||||
# await ctx.send_str(200, 'Hello World')
|
||||
|
||||
|
||||
app = BugisApp()
|
||||
@@ -16,5 +17,35 @@ app = BugisApp()
|
||||
@app.GET('/hello2')
|
||||
async def handle_request(ctx: HttpContext) -> None:
|
||||
async for chunk in ctx.request_body:
|
||||
print(chunk)
|
||||
await ctx.send_str(200, 'Hello World')
|
||||
print(chunk.decode())
|
||||
await ctx.send_str(200, 'Hello World')
|
||||
|
||||
@app.GET('/hello/alice')
|
||||
async def hello_alice(ctx: HttpContext) -> None:
|
||||
async for _ in ctx.request_body:
|
||||
pass
|
||||
await ctx.send_str(200, 'Hello Alice 2')
|
||||
|
||||
@app.GET('/hello/*')
|
||||
async def hello_alice(ctx: HttpContext, args: List[str]) -> None:
|
||||
async for _ in ctx.request_body:
|
||||
pass
|
||||
await ctx.send_str(200, f'Hello {args[0]}')
|
||||
|
||||
@app.GET('/hello/*/kennedy')
|
||||
async def hello_alice(ctx: HttpContext, args: List[str]) -> None:
|
||||
async for _ in ctx.request_body:
|
||||
pass
|
||||
await ctx.send_str(200, f'Hello {args[0]} kennedy')
|
||||
|
||||
@app.GET('/hello/bob/marley')
|
||||
async def hello_alice(ctx: HttpContext) -> None:
|
||||
async for _ in ctx.request_body:
|
||||
pass
|
||||
await ctx.send_str(200, f'Hello bob Marley')
|
||||
|
||||
@app.route('/hello/*', HttpMethod.PUT, recursive=True)
|
||||
async def handle_request(ctx: HttpContext, _: List[str]) -> None:
|
||||
async for chunk in ctx.request_body:
|
||||
print(chunk.decode())
|
||||
await ctx.send_str(200, 'Message received')
|
||||
Reference in New Issue
Block a user