def set_route_problem(api: responder.API) -> None:
    problem_controller = ProblemController(SqlHandler("problem"))

    api.add_route("/contest/{contest_id}/problems",
                  problem_controller.problems)
    api.add_route(
        "/contest/{contest_id}/problems/{problem_id}",
        problem_controller.problem,
    )
def set_route_submittion(api: responder.API) -> None:
    submittion_controller = SubmittionController(SqlHandler("submittion"))

    api.add_route(
        "/contest/{contest_id}/problems/{problem_id}/submit",
        submittion_controller.submit,
    )
    # contest_idで紐づいたそのコンテストの提出リストとかほしい
    api.add_route(
        "/contest/{contest_id}/submittions/{problem_id}",
        submittion_controller.submittions,
    )
    api.add_route(
        "/contest/{contest_id}/submittions/{problem_id}/{submit_id}",
        submittion_controller.submittion,
    )
Exemple #3
0
from responder import API

api = API()
print(api.background)
print(vars(api.background))

import sys
from responder import API
from starlette.testclient import TestClient

from server.wsgi import application

api = API()
api.requests = api._session = TestClient(api,
                                         base_url="http://www.deephigh.net")
api.mount("", application)

if __name__ == "__main__":
    port = int(sys.argv[1])
    api.run(address="0.0.0.0", port=port)
                           "APIKey": []
                       }])
        spec.components.security_scheme("APIKey", api_key_header)

        for route in self.routes:
            if self.routes[route].description:
                operations = yaml_utils.load_operations_from_docstring(
                    self.routes[route].description)
                spec.path(path=route, operations=operations)

        for name, schema in self.schemas.items():
            spec.components.schema(name, schema=schema)

        return spec


api = API(
    title='Conftalks API',
    version='0.1',
    openapi='3.0.2',
    docs_route='/',
    contact=contact,
    description=api_description,
)

if __name__ == '__main__':
    from events import *
    from users import *
    from conferences import *
    api.run(debug=True)
Exemple #6
0
from responder import API

mock_api: API = API()
Exemple #7
0
# auto gen
from responder import API, Request, Response
from requests_oauthlib import OAuth1Session

from auth import authenticate, oauth_callback
from api_keys import DEBUG
from views import *


if DEBUG:
    api = API(cors=True, cors_params={
        'allow_origins': ['http://localhost', 'http://localhost:8000'],
        'allow_methods': ['GET', 'POST'],
        'allow_headers': ['*'],
    })
else:
    api = API()

api.add_route('/authenticate', authenticate)
api.add_route('/oauth_callback/', oauth_callback)


api.add_route('/account/settings', Account.Settings)
api.add_route('/account/verify_credentials', Account.Verify_Credentials)
api.add_route('/account/remove_profile_banner', Account.Remove_Profile_Banner)
api.add_route('/account/update_profile', Account.Update_Profile)
api.add_route('/account/update_profile_banner', Account.Update_Profile_Banner)
api.add_route('/account/update_profile_image', Account.Update_Profile_Image)
api.add_route('/users/profile_banner', Users.Profile_Banner)
api.add_route('/users/lookup', Users.Lookup)
api.add_route('/users/search', Users.Search)
def set_route_user(api: responder.API) -> None:
    user_controller = UserController(SqlHandler("doj_user"))

    api.add_route("/user/create", user_controller.create)
    api.add_route("/users", user_controller.users)
def set_route_contest(api: responder.API) -> None:
    contest_controller = ContestController(SqlHandler("contest"))

    api.add_route("/contests", contest_controller.contests)
    api.add_route("/contest/{contest_id}", contest_controller.contest)
Exemple #10
0
from responder import API

movie_client: API = API()
from pathlib import Path
from io import BytesIO

from responder import API
from aiohttp import ClientSession
import asyncio

from fastai.vision import (
    load_learner,
    defaults,
    open_image
)
from torch import device

defaults.device = device('cpu')
app = API()

export_file_url = 'https://drive.google.com/uc?id=1n8L9ZEaSJgfbQs9Vb9cUrHLHhFVTQiQI&export=download'
export_file_name = 'export.pkl'
path = Path(__file__).parent

async def get_bytes(url):
    async with ClientSession() as session:
        async with session.get(url) as response:
            return await response.read()

async def download_file(url, dest):
    if dest.exists():
        return
    data = await get_bytes(url)
    with open(dest, 'wb') as f:
Exemple #12
0
 def register(self, api: API):
     for route, endpoint, options in self._routes:
         api.add_route(f"{self._prefix}{route}", endpoint, **options)
Exemple #13
0
from responder import API, Request, Response
import schema
from models import database, create_tables, Kigo, Image, Haiku
from peewee import SQL, fn
from collections import Counter
from base64 import urlsafe_b64encode
from uuid import uuid1

api = API(cors=True,
          cors_params={
              'allow_origins': ['*'],
              'allow_methods': ['*'],
              'allow_headers': ['*'],
          })


@api.route('/haiku')
class HaikuResource:
    async def on_get(self, req: Request, resp: Response):
        """
        response
        [
          {
            "first": "柿くへば",
            "second": "鐘が鳴るなり",
            "third": "法隆寺",
            "kigo": "柿",
            "season": "fall"
          }
        ]
        """