예제 #1
0
    def second(request: Request):
        session = request.session

        assert "foo" in session
        assert session["foo"] == "Some value"

        return text("Hello, World")
예제 #2
0
    def home(request: Request):
        session = request.session

        assert isinstance(session, Session)
        session["foo"] = "Some value"

        return text("Hello, World")
예제 #3
0
    def home(request: Request):
        session = request.session

        assert isinstance(session, Session)
        assert len(session) == 0
        assert "user_id" not in session

        return text("Hello, World")
예제 #4
0
async def view_upload(request):
    """Load multipart data and store it as a file."""
    formdata = await request.form()
    if formdata is None or 'file' not in formdata:
        return bad_request()

    with open(f"/tmp/{uuid4().hex}", 'w') as target:
        target.write(formdata['file'])

    return text(target.name)
예제 #5
0
    async def handler(request: Request) -> Response:
        result = await method(request)

        if result is None:
            # later the application defaults to 204 No Content
            return result

        if not isinstance(result, Response):
            # default to a plain text or JSON response
            if isinstance(result, str):
                return responses.text(result)
            return responses.json(result)

        return result
예제 #6
0
        def update_cat(self): return text('6')

        @post()
예제 #7
0
        def create_cat(self): return text('7')

        @delete(':cat_id')
예제 #8
0
 async def home():
     return text("Hi There!")
예제 #9
0
async def user(_):
    return text(f"")
예제 #10
0
 async def home():
     return text("Hello World")
예제 #11
0
 def text(self, value: str, status: int = 200) -> Response:
     """
     Returns a response with text/plain content,
     and given status (default HTTP 200 OK).
     """
     return text(value, status)
예제 #12
0
 async def index(self, request: Request, user: Optional[User]):
     assert hasattr(request, 'identity')
     assert isinstance(request.identity, User)
     return text(request.identity.name)
예제 #13
0
파일: app.py 프로젝트: perfmjs/BlackSheep
async def hello_world():
    return text(f'Hello, World!')
예제 #14
0
 async def index(self, request: Request):
     return text(self.greet())
예제 #15
0
 async def foo(self, request: Request):
     return text('foo')
예제 #16
0
def not_documented():
    return text("Ignored because catch-all")
예제 #17
0
def bark(example: FromCookie[str], example_header: FromHeader[str]):
    return text("Bau Bau")
예제 #18
0
async def home(request):
    return text(f'Hello, World! {datetime.utcnow().isoformat()}')
예제 #19
0
        def delete_cat(self): return text('8')

    app.setup_controllers()
예제 #20
0
 async def foo(self):
     assert isinstance(self, Home)
     return text('foo')
예제 #21
0
파일: app.py 프로젝트: perfmjs/BlackSheep
async def echo_chunked_text(request):
    text_from_client = await request.text()
    return text(text_from_client)
예제 #22
0
 async def index(self, request: Request):
     assert isinstance(self, Home)
     return text(self.greet())
예제 #23
0
파일: app.py 프로젝트: perfmjs/BlackSheep
async def set_cookies(name: FromQuery(str), value: FromQuery(str)):
    response = text('Setting cookie')
    response.set_cookie(Cookie(name.encode(), value.encode()))
    return response
예제 #24
0
async def user_info(_, id: int):
    return text(f"{id}")
예제 #25
0
 async def home():
     return text(content, status)
예제 #26
0
        def delete_cat(self): return text('4')

    # noinspection PyUnusedLocal
    class CatV2(ApiController):
async def home(request):
    return text(f'Hello, World!')
예제 #28
0
        def get_cat(self, cat_id: str): return text('5')

        @patch()
예제 #29
0
 def alive(self):
     return text('Good')
예제 #30
0
    def second(request: Request):
        session = request.session

        assert "foo" not in session

        return text("Hello, World")