forked from extern/podman-compose
reformat
This commit is contained in:
parent
75033a4ed7
commit
ee7029fbde
@ -4,30 +4,34 @@ import asyncio
|
|||||||
import aioredis
|
import aioredis
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
|
||||||
REDIS_HOST = os.environ.get('REDIS_HOST', 'localhost')
|
REDIS_HOST = os.environ.get("REDIS_HOST", "localhost")
|
||||||
REDIS_PORT = int(os.environ.get('REDIS_PORT', '6379'))
|
REDIS_PORT = int(os.environ.get("REDIS_PORT", "6379"))
|
||||||
REDIS_DB = int(os.environ.get('REDIS_DB', '0'))
|
REDIS_DB = int(os.environ.get("REDIS_DB", "0"))
|
||||||
|
|
||||||
redis = aioredis.from_url(f"redis://{REDIS_HOST}:{REDIS_PORT}/{REDIS_DB}")
|
redis = aioredis.from_url(f"redis://{REDIS_HOST}:{REDIS_PORT}/{REDIS_DB}")
|
||||||
app = web.Application()
|
app = web.Application()
|
||||||
routes = web.RouteTableDef()
|
routes = web.RouteTableDef()
|
||||||
|
|
||||||
@routes.get('/')
|
|
||||||
|
@routes.get("/")
|
||||||
async def hello(request):
|
async def hello(request):
|
||||||
counter = await redis.incr("mycounter")
|
counter = await redis.incr("mycounter")
|
||||||
return web.Response(text=f"counter={counter}")
|
return web.Response(text=f"counter={counter}")
|
||||||
|
|
||||||
@routes.get('/hello.json')
|
|
||||||
|
@routes.get("/hello.json")
|
||||||
async def hello_json(request):
|
async def hello_json(request):
|
||||||
counter = await redis.incr("mycounter")
|
counter = await redis.incr("mycounter")
|
||||||
data = {'counter': counter}
|
data = {"counter": counter}
|
||||||
return web.json_response(data)
|
return web.json_response(data)
|
||||||
|
|
||||||
|
|
||||||
app.add_routes(routes)
|
app.add_routes(routes)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
web.run_app(app)
|
web.run_app(app)
|
||||||
|
|
||||||
if __name__=='__main__':
|
|
||||||
main()
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user