23 lines
579 B
Python
23 lines
579 B
Python
"""Create a simple API to the bot."""
|
|
from aiohttp import web
|
|
|
|
|
|
async def index(request):
|
|
"""Provide a basic index to the API."""
|
|
return web.Response(text="hitomi")
|
|
|
|
|
|
async def greet(request):
|
|
"""Provide a simple greeting."""
|
|
name = request.match_info.get('name', 'Anonymous')
|
|
text = "Hello {0:s}".format(name)
|
|
return web.Response(text=text)
|
|
|
|
# initialize the API
|
|
hitomi_api = web.Application()
|
|
|
|
# add our basic stuff above
|
|
hitomi_api.router.add_get('/', index)
|
|
hitomi_api.router.add_get('/greet', greet)
|
|
hitomi_api.router.add_get('/greet/{name}', greet)
|