예제 #1
0
async def welcome2(
    request: Request, name: fields.Str(missing="Friend",
                                       location="querystring")
) -> Response:
    """A welcome page, using a field annotation."""
    return JSONResponse({"message": f"Welcome, {name}!"})
예제 #2
0
async def test(request):
    return JSONResponse("its lit")
예제 #3
0
async def analyze(request):
    data = await request.form()
    img_bytes = await (data['file'].read())
    img = open_image(BytesIO(img_bytes))
    prediction = learn.predict(img)[0]
    return JSONResponse({'result': str(prediction)})
예제 #4
0
async def register(request: Request):
    input: RegisterUserInput = await parse(RegisterUserInput.parse, request)
    return JSONResponse(UserSchema().dump(input.user))
예제 #5
0
async def get_open_api_endpoint():
    return JSONResponse(
        get_openapi(title="FastAPI", routes=app.routes, version="2"))
예제 #6
0
파일: main.py 프로젝트: ongying8/Workshop3
def index():
    return JSONResponse(content={"message": "Hello,  World"}, status_code=200)
예제 #7
0
async def analyze(request):
    data = await request.form()

    return JSONResponse({'result': textResponse(data)})
예제 #8
0
 async def swagger_config_handler(request):
     host = '{}:{}'.format(request.url.hostname, request.url.port)
     return JSONResponse(doc.get_config(host))
예제 #9
0
 async def swagger_editor_handler(request):
     return JSONResponse(content=doc.editor_html, media_type='text/html')
예제 #10
0
async def http_exception(request: Request,
                         exc: WebargsHTTPException) -> Response:
    return JSONResponse(exc.messages,
                        status_code=exc.status_code,
                        headers=exc.headers)
예제 #11
0
async def register(form: Credentials) -> JSONResponse:
    if User.find(username=form.username):
        raise HTTPException(400, "User with this username already exists")
    user = User.register(form.username, form.password)
    user.write()
    return JSONResponse({"success": True})
예제 #12
0
 async def post(self, request: Request, x: float, y: float) -> Response:
     return JSONResponse({"result": x + y})
예제 #13
0
async def add(request: Request, x: float, y: float) -> Response:
    """An addition endpoint."""
    return JSONResponse({"result": x + y})
예제 #14
0
async def welcome_no_default(request: Request, name: str) -> Response:
    """A welcome page with no default name. If "name" isn't passed in the querystring,
    an error response will be returned.
    """
    return JSONResponse({"message": f"Welcome, {name}!"})
예제 #15
0
def default(req):
    return JSONResponse([{"id": 1, "name": "foo"}, {"id": 2, "name": "bar"}])
예제 #16
0
파일: main.py 프로젝트: arthur-FD/fastapi-1
async def get_open_api_endpoint(api_key: APIKey = Depends(get_api_key)):
    response = JSONResponse(
        get_openapi(title="FastAPI security test", version=1, routes=app.routes)
    )
    return response
예제 #17
0
파일: app.py 프로젝트: fossabot/baka-chat
async def stat(request: Request):
    # current_version: 2020-03-12_1584028278
    version_str = oss.key_to_version(current_version)
    return JSONResponse({"version": version_str, "net_meta": session.hparams})
예제 #18
0
async def answers_to_hw(request):
    return JSONResponse(
        [answer_question_1, answer_question_2, answer_question_3])
예제 #19
0
async def get_workers():
    return JSONResponse(status_code=status.HTTP_200_OK,
                        content=con.worker_online)
예제 #20
0
async def class_list(request):
    return JSONResponse(['nes', 'supern', 'n64', 'gamecube'])
예제 #21
0
    async def get(self, request, *args, **kwargs):
        """."""

        return JSONResponse({'hello': 'World'})
예제 #22
0
async def root(request):
    return JSONResponse({"ms": "Welcome to Notes app."})
예제 #23
0
파일: justpy.py 프로젝트: kudralex/justpy
 async def on_disconnect(self, page_id):
     logging.debug(f'In disconnect Homepage')
     await WebPage.instances[page_id].on_disconnect(
     )  # Run the specific page disconnect function
     return JSONResponse(False)
예제 #24
0
 async def _http_error_handler(_: Request,
                               exc: Type[BaseException]) -> JSONResponse:
     assert isinstance(exc, exception_cls)  # nosec
     return JSONResponse(content=jsonable_encoder({"errors": [str(exc)]}),
                         status_code=status_code)
예제 #25
0
async def http_error_handler(_: Request, exc: HTTPException) -> JSONResponse:
    return JSONResponse({"errors": [exc.detail]}, status_code=exc.status_code)
예제 #26
0
async def http_error_handler(_: Request, exc: HTTPException) -> JSONResponse:
    return JSONResponse(content=jsonable_encoder({"errors": [exc.detail]}),
                        status_code=exc.status_code)
예제 #27
0
async def gang(request):
    img_data = await request.form('img')
    prediction = learn.predict(img_data)[0]
    return JSONResponse({'result': str(prediction)})
예제 #28
0
async def catch_exceptions_middleware(request: Request, call_next):
    try:
        return await call_next(request)
    except Exception as err:
        return JSONResponse(content={"error": f"Internal server error: {err}"}, status_code=500)
예제 #29
0
async def index(request: Request) -> Response:
    return JSONResponse({"exists": context.exists()})
예제 #30
0
async def welcome(request: Request, name: str = "Friend") -> Response:
    """A welcome page."""
    return JSONResponse({"message": f"Welcome, {name}!"})