How to use the aiohttp.web.post function in aiohttp

To help you get started, we’ve selected a few aiohttp 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 samuelcolvin / aiohttp-toolbox / tests / demo / main.py View on Github external
async def create_app(settings):
    routes = [
        web.get('/', handle_200, name='index'),
        web.route('*', r'/status/{status:\d+}/', return_any_status, name='any-status'),
        web.get('/user/', handle_user),
        web.get('/request-context/', request_context),
        web.get('/errors/{do}', handle_errors),
        web.route('*', '/exec/', TestExecView.view()),
        web.route('*', '/exec-simple/', TestSimpleExecView.view()),
        web.get('/encrypt/', encrypt),
        web.get('/decrypt/', decrypt),
        web.post('/grecaptcha/', grecaptcha),
        web.post('/upload-path/', handle_200),
        web.get('/spa/{path:.*}', spa_static_handler),
        *OrganisationBread.routes('/orgs/'),
    ]
    app = await create_default_app(settings=settings, routes=routes)
    app.update(middleware_log_user=get_user, static_dir=THIS_DIR / 'static')
    return app
github samuelcolvin / aiohttp-toolbox / atoolbox / test_utils.py View on Github external
def create_dummy_app() -> Application:
    app = web.Application(middlewares=(log_middleware,))
    app.add_routes(
        [
            web.route('*', r'/status/{status:\d+}/', return_any_status, name='any-status'),
            web.post('/grecaptcha_url/', grecaptcha_dummy, name='grecaptcha-dummy'),
        ]
    )
    app['log'] = []
    return app
github hyperledger / indy-agent / test-suite / transport / http_transport.py View on Github external
async def start_server(self):
        """ The main task for the server aspect of transport.
        """
        APP = web.Application()
        ROUTES = [
            web.post('/indy', self.handle_message)
        ]
        APP.add_routes(ROUTES)
        RUNNER = web.AppRunner(APP)
        await RUNNER.setup()
        SERVER = web.TCPSite(RUNNER, self.config.host, self.config.port)
        self.logger.info('Starting Server on: http://{}:{}'.format(self.config.host, self.config.port))
        await SERVER.start()
github home-assistant / hassio-supervisor / hassio / api / __init__.py View on Github external
"""Register Home Assistant functions."""
        api_hass = APIHomeAssistant()
        api_hass.coresys = self.coresys

        self.webapp.add_routes(
            [
                web.get("/homeassistant/info", api_hass.info),
                web.get("/homeassistant/logs", api_hass.logs),
                web.get("/homeassistant/stats", api_hass.stats),
                web.post("/homeassistant/options", api_hass.options),
                web.post("/homeassistant/update", api_hass.update),
                web.post("/homeassistant/restart", api_hass.restart),
                web.post("/homeassistant/stop", api_hass.stop),
                web.post("/homeassistant/start", api_hass.start),
                web.post("/homeassistant/check", api_hass.check),
                web.post("/homeassistant/rebuild", api_hass.rebuild),
            ]
github samuelcolvin / nosht / py / web / main.py View on Github external
r'/events/{id:\d+}/set-image/existing/', set_event_image_existing, name='event-set-image-existing'
            ),
            web.post(
                r'/events/{id:\d+}/set-image/secondary/', set_event_secondary_image, name='event-set-image-secondary'
            ),
            web.post(
                r'/events/{id:\d+}/remove-image/secondary/',
                remove_event_secondary_image,
                name='event-remove-image-secondary',
            ),
            web.post(r'/events/{id:\d+}/clone/', EventClone.view(), name='event-clone'),
            web.get(r'/events/{id:\d+}/tickets/', event_tickets, name='event-tickets'),
            web.post(r'/events/{id:\d+}/tickets/{tid:\d+}/cancel/', CancelTickets.view(), name='event-tickets-cancel'),
            web.get(r'/events/{id:\d+}/tickets/export.csv', event_tickets_export, name='event-tickets-export'),
            web.get(r'/events/{id:\d+}/ticket-types/', event_ticket_types, name='event-ticket-types'),
            web.post(r'/events/{id:\d+}/ticket-types/update/', SetTicketTypes.view(), name='update-event-ticket-types'),
            web.post(r'/events/{id:\d+}/reserve/', ReserveTickets.view(), name='event-reserve-tickets'),
            web.post(r'/events/{id:\d+}/updates/send/', EventUpdate.view(), name='event-send-update'),
            web.get(r'/events/{id:\d+}/updates/list/', event_updates_sent, name='event-updates-sent'),
            web.post(r'/events/{id:\d+}/switch-highlight/', switch_highlight, name='event-switch-highlight'),
            web.post(r'/events/{id:\d+}/waiting-list/add/', waiting_list_add, name='event-waiting-list-add'),
            web.get(
                r'/events/{id:\d+}/waiting-list/remove/{user_id:\d+}/',
                waiting_list_remove,
                name='event-waiting-list-remove',
            ),
            # event public views
            web.post(r'/events/book-free/', BookFreeTickets.view(), name='event-book-tickets'),
            web.post(r'/events/cancel-reservation/', CancelReservedTickets.view(), name='event-cancel-reservation'),
            web.get(r'/events/{category}/{event}/', event_get, name='event-get-public'),
            web.get(r'/events/{category}/{event}/booking-info/', booking_info, name='event-booking-info-public'),
            web.get(r'/events/{category}/{event}/{sig}/', event_get, name='event-get-private'),
github algoo / hapic / example / example_a_aiohttp.py View on Github external
async def do_login(request):
    data = await request.json()
    login = data['login']
    password = data['password']

    return web.json_response({
        'login': login,
    })

app = web.Application(debug=True)
app.add_routes([
    web.get('/n/', display_name),
    web.get('/n/{name}', display_name),
    web.post('/n/{name}', display_name),
    web.post('/b/', display_body),
    web.post('/login', do_login),
])


hapic.set_context(AiohttpContext(app, default_error_builder=MarshmallowDefaultErrorBuilder()))


# import json
# import yaml
# print(yaml.dump(
#     json.loads(json.dumps(hapic.generate_doc())),
#     default_flow_style=False,
# ))

web.run_app(app)
github hyperledger / aries-cloudagent-python / aries_cloudagent / protocols / presentations / routes.py View on Github external
"/presentation_exchange/{id}/credentials",
                presentation_exchange_credentials_list,
            ),
            web.get(
                "/presentation_exchange/{id}/credentials/{referent}",
                presentation_exchange_credentials_list,
            ),
            web.post(
                "/presentation_exchange/create_request",
                presentation_exchange_create_request,
            ),
            web.post(
                "/presentation_exchange/send_request",
                presentation_exchange_send_request,
            ),
            web.post(
                "/presentation_exchange/{id}/send_presentation",
                presentation_exchange_send_credential_presentation,
            ),
            web.post(
                "/presentation_exchange/{id}/verify_presentation",
                presentation_exchange_verify_credential_presentation,
            ),
            web.post(
                "/presentation_exchange/{id}/remove", presentation_exchange_remove
            ),
github hyperledger / aries-cloudagent-python / aries_cloudagent / protocols / credentials / routes.py View on Github external
async def register(app: web.Application):
    """Register routes."""

    app.add_routes(
        [
            web.get("/credential/{id}", credentials_get),
            web.post("/credential/{id}/remove", credentials_remove),
            web.get("/credentials", credentials_list),
            web.get("/credential_exchange", credential_exchange_list),
            web.get("/credential_exchange/{id}", credential_exchange_retrieve),
            web.post("/credential_exchange/send", credential_exchange_send),
            web.post("/credential_exchange/send-offer", credential_exchange_send_offer),
            web.post(
                "/credential_exchange/{id}/send-request",
                credential_exchange_send_request,
            ),
            web.post("/credential_exchange/{id}/issue", credential_exchange_issue),
            web.post("/credential_exchange/{id}/store", credential_exchange_store),
            web.post(
                "/credential_exchange/{id}/problem_report",
                credential_exchange_problem_report,
            ),
            web.post("/credential_exchange/{id}/remove", credential_exchange_remove),
        ]
github ScratchVerifier / ScratchVerifier / backend / server.py View on Github external
def __init__(self, hook_secret, discord_hook, name=None):
        self.app = web.Application(middlewares=[self.errors])
        self.app.add_routes([
            web.put('/verify/{username}', self.verify),
            web.post('/verify/{username}', self.verified),
            web.delete('/verify/{username}', self.unverify),
            web.post('/users/{username}/login', self.login),
            web.post('/users/{username}/finish-login', self.finish_login),
            web.post('/users/{username}/logout', self.logout_user),
            web.get('/session/{session}', self.get_user),
            web.put('/session/{session}', self.put_user),
            web.patch('/session/{session}', self.reset_token),
            web.delete('/session/{session}', self.del_user),
            web.post('/session/{session}/logout', self.logout),
            web.get('/usage', self.logs),
            web.get('/usage/{logid}', self.log),
            web.post('/webhook', self.gh_hook),
            web.get('/site/{path:.*}', self.file_handler),
            web.get('/site/', self.file_handler),
            web.get('/site', self.file_handler),
            web.get('/docs/{path:.*}', self.docs_handler),
            web.get('/docs/', self.docs_handler),
            web.get('/docs', self.docs_handler),
            web.post('/debug/{dibool}', self.set_debug),
            web.view('/{path:.*}', self.not_found)
github home-assistant / hassio-supervisor / hassio / api / __init__.py View on Github external
def _register_snapshots(self) -> None:
        """Register snapshots functions."""
        api_snapshots = APISnapshots()
        api_snapshots.coresys = self.coresys

        self.webapp.add_routes(
            [
                web.get("/snapshots", api_snapshots.list),
                web.post("/snapshots/reload", api_snapshots.reload),
                web.post("/snapshots/new/full", api_snapshots.snapshot_full),
                web.post("/snapshots/new/partial", api_snapshots.snapshot_partial),
                web.post("/snapshots/new/upload", api_snapshots.upload),
                web.get("/snapshots/{snapshot}/info", api_snapshots.info),
                web.post("/snapshots/{snapshot}/remove", api_snapshots.remove),
                web.post(
                    "/snapshots/{snapshot}/restore/full", api_snapshots.restore_full
                ),
                web.post(
                    "/snapshots/{snapshot}/restore/partial",
                    api_snapshots.restore_partial,
                ),
                web.get("/snapshots/{snapshot}/download", api_snapshots.download),
            ]