def not_found(self, scope: Scope) -> ASGIInstance: return Response("Not found", 404, media_type="text/plain")
async def __call__(self, receive, send): response = Response(content, media_type="text/html") await response(receive, send)
def app(request): return Response("hello, world", media_type="text/plain")
def __call__(self, scope: Scope) -> ASGIInstance: if self.methods and scope["method"] not in self.methods: return Response("Method not allowed", 406, media_type="text/plain") return self.app(scope)
async def app(request): body = await request.body() return Response(body, media_type="text/plain")
def users(scope): return Response("All users", media_type="text/plain")
def homepage(scope): return Response("Hello, world", media_type="text/plain")
def staticfiles(scope): return Response("xxxxx", media_type="image/png")
def user(scope): content = "User " + scope["kwargs"]["username"] return Response(content, media_type="text/plain")