How to use the tomodachi.http function in tomodachi

To help you get started, we’ve selected a few tomodachi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kalaspuff / tomodachi / examples / http_service.py View on Github external
    @http('GET', r'/response/?')
    async def response_object(self, request: web.Request) -> HttpResponse:
        return HttpResponse(body='{"data": true}', status=200, content_type='application/json')
github kalaspuff / tomodachi / examples / docker_example / http_service / app / service.py View on Github external
    @tomodachi.http('GET', r'/health')
    async def health_check(self, request):
        return 'healthy'
github kalaspuff / tomodachi / examples / basic_examples / http_auth_service.py View on Github external
    @http('POST', r'/validate/?')
    @require_auth_token
    async def validate(self, request: web.Request) -> str:
        return 'Valid auth token!'
github kalaspuff / tomodachi / examples / basic_examples / http_auth_service.py View on Github external
    @http('GET', r'/get-token/?')
    async def get_token(self, request: web.Request) -> str:
        return self.allowed_token
github kalaspuff / tomodachi / examples / basic_examples / http_middleware_service.py View on Github external
    @http('GET', r'/example/(?P[^/]+?)/?')
    async def example_with_id(self, request: web.Request, id: str, **kwargs: Any) -> str:
        return '友達 (id: {})'.format(id)
github kalaspuff / tomodachi / examples / basic_examples / http_simple_service.py View on Github external
    @http('GET', r'/example/(?P[^/]+?)/?')
    async def example_with_id(self, request: web.Request, id: str) -> str:
        return '友達 (id: {})'.format(id)
github kalaspuff / tomodachi / examples / docker_example / http_service / app / service.py View on Github external
    @tomodachi.http('GET', r'/')
    async def index_endpoint(self, request):
        return 'friends forever!'
github kalaspuff / tomodachi / examples / basic_examples / http_simple_service.py View on Github external
    @http('GET', r'/response/?')
    async def response_object(self, request: web.Request) -> HttpResponse:
        return HttpResponse(body='{"data": true}', status=200, content_type='application/json')
github kalaspuff / tomodachi / examples / basic_examples / websockets / websocket_service.py View on Github external
    @http('GET', r'/(?:|index.html)')
    async def index(self, request: web.Request) -> web.Response:
        path = '{}/{}'.format(os.path.dirname(self.context.get('context', {}).get('_service_file_path')), 'public/index.html')
        response = FileResponse(path=path,  # type: ignore
                                chunk_size=256 * 1024)  # type: web.Response
        return response