示例#1
0
 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)
示例#3
0
 def app(request):
     return Response("hello, world", media_type="text/plain")
示例#4
0
 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)
示例#5
0
 async def app(request):
     body = await request.body()
     return Response(body, media_type="text/plain")
示例#6
0
def users(scope):
    return Response("All users", media_type="text/plain")
示例#7
0
def homepage(scope):
    return Response("Hello, world", media_type="text/plain")
示例#8
0
def staticfiles(scope):
    return Response("xxxxx", media_type="image/png")
示例#9
0
def user(scope):
    content = "User " + scope["kwargs"]["username"]
    return Response(content, media_type="text/plain")