Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def schema(request: web.Request) -> web.Response:
content = yaml.dump(schema_data)
schema_requests.append(request)
return web.Response(body=content)
def wrapper(handler: Callable) -> Callable:
@wraps(handler)
async def inner(request: web.Request) -> web.Response:
incoming_requests.append(request)
return await handler(request)
return inner
app = web.Application()
app.add_routes(
[web.get("/swagger.yaml", schema)]
+ [
web.route(item.value[0], item.value[1], wrapper(item.value[2]))
for item in Endpoint
if item.name in endpoints
]
)
app["incoming_requests"] = incoming_requests
app["schema_requests"] = schema_requests
return app
async def register(app: web.Application):
"""Register routes."""
app.add_routes(
[
web.get(
"/present-proof/records", presentation_exchange_list, allow_head=False
),
web.get(
"/present-proof/records/{pres_ex_id}",
presentation_exchange_retrieve,
allow_head=False,
),
web.get(
"/present-proof/records/{pres_ex_id}/credentials",
presentation_exchange_credentials_list,
allow_head=False,
),
web.post(
"/present-proof/send-proposal", presentation_exchange_send_proposal,
),
web.post(
"/present-proof/create-request", presentation_exchange_create_request,
),
web.post(
"/present-proof/send-request", presentation_exchange_send_free_request,
),
web.post(
"/present-proof/records/{pres_ex_id}/send-request",
presentation_exchange_send_bound_request,
def setup_routes(self):
self.app.add_routes([web.get('/circuits/slots', self.get_circuit_slots),
web.get('/open_files', self.get_open_files),
web.get('/open_sockets', self.get_open_sockets),
web.get('/threads', self.get_threads),
web.get('/cpu/history', self.get_cpu_history),
web.get('/memory/history', self.get_memory_history),
web.get('/log', self.get_log),
web.get('/profiler', self.get_profiler_state),
web.put('/profiler', self.start_profiler),
web.delete('/profiler', self.stop_profiler)])
if HAS_MELIAE:
self.app.add_routes(web.get('/memory/dump', self.get_memory_dump))
def setup_app(app: web.Application) -> None:
if SPEC_ROUTE and "spec" in app:
app.add_routes([web.get(SPEC_ROUTE, spec_root)])
self.db = db
self.logger = logger
self.prefix = prefix
self.sessions = {}
self.client_id = client_id
self.client_secret = client_secret
self.web_root = web_root
self.root = document_root
self.app = web.Application()
self.app.add_routes([
web.get('/', self.index),
web.get('/login', self.login),
web.get('/settings', self.settings),
web.post('/settings', self.save_settings),
web.get('/servers', self.servers),
web.get(r'/servers/{server:\d+}', self.server),
web.post(r'/servers/{server:\d+}', self.save_server),
web.get(r'/{name:.+(?
from aiohttp import web
from pulpcore.content import app
from pulp_docker.app.registry import Registry
from pulp_docker.app.authorization import AuthorizationService
registry = Registry()
app.add_routes([web.get('/v2/', Registry.serve_v2)])
app.add_routes([web.get(r'/v2/{path:.+}/blobs/sha256:{digest:.+}', registry.get_by_digest)])
app.add_routes([web.get(r'/v2/{path:.+}/manifests/sha256:{digest:.+}', registry.get_by_digest)])
app.add_routes([web.get(r'/v2/{path:.+}/manifests/{tag_name}', registry.get_tag)])
app.add_routes([web.get(r'/v2/{path:.+}/tags/list', registry.tags_list)])
authorization_service = AuthorizationService()
app.add_routes([web.get('/token', authorization_service.generate_token)])
server = web.Application()
async def lightning_cache(request):
return await cache_server(blitzortung.strikeCache, request)
server.add_routes([web.get('/lightning_cache', lightning_cache)])
async def mesocyclone_cache(request):
return await cache_server(meso.cache, request)
server.add_routes([web.get('/mesocyclones/all/', mesocyclone_cache)])
async def mesocyclone_one(request):
attribs = None
try:
ts = int(request.match_info.get('id', 0))
attribs = meso.attributes[ts]
except ValueError:
return web.json_response({'error': 'invalid id'})
return web.json_response(attribs)
server.add_routes([web.get('/mesocyclones/{id}', mesocyclone_one)])
web.run_app(server, port=5000)
data = CharField(max_length=64, null=False)
created_at = DateTimeField()
async def show_handle(request):
datas = [t.data for t in await Test.select()]
return web.Response(text = u"<br>".join(datas))
async def create_handle(request):
data = await request.post()
data = data["data"]
await Test.create(data=data, created_at=datetime.datetime.now())
return web.HTTPFound('/')
app = web.Application()
app.add_routes([
web.get('/', show_handle),
web.post('/', create_handle)
])
web.run_app(app)