panoramisk.fast_agi - Fast AGI

An API to create Fast AGI applications

API

class panoramisk.fast_agi.Application(default_encoding='utf-8', loop=None)[source]

Main object:

>>> fa_app = Application()
add_route(path, endpoint)[source]

Add a route for FastAGI requests:

Parameters:
  • path (String) – URI to answer. Ex: ‘calls/start’
  • endpoint (callable) – command to launch. Ex: start
Example:
@asyncio.coroutine
def start(request):
    print('Receive a FastAGI request')
    print(['AGI variables:', request.headers])

fa_app = Application()
fa_app.add_route('calls/start', start)
del_route(path)[source]

Delete a route for FastAGI requests:

Parameters:path (String) – URI to answer. Ex: ‘calls/start’
Example:
@asyncio.coroutine
def start(request):
    print('Receive a FastAGI request')
    print(['AGI variables:', request.headers])

fa_app = Application()
fa_app.add_route('calls/start', start)
fa_app.del_route('calls/start')
handler(reader, writer)[source]

AsyncIO coroutine handler to launch socket listening.

Example:
@asyncio.coroutine
def start(request):
    print('Receive a FastAGI request')
    print(['AGI variables:', request.headers])

fa_app = Application()
fa_app.add_route('calls/start', start)
coro = asyncio.start_server(fa_app.handler, '0.0.0.0', 4574)
server = loop.run_until_complete(coro)

See https://docs.python.org/3/library/asyncio-stream.html