mirror of
https://github.com/containers/podman-compose.git
synced 2025-06-05 20:46:47 +02:00
examples: Add type annotations
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
This commit is contained in:
parent
5765e5306b
commit
3c2978c9ca
@ -3,8 +3,8 @@
|
|||||||
import asyncio # noqa: F401
|
import asyncio # noqa: F401
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import aioredis
|
import aioredis # type: ignore[import-not-found]
|
||||||
from aiohttp import web
|
from aiohttp import web # type: ignore[import-not-found]
|
||||||
|
|
||||||
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"))
|
||||||
@ -16,13 +16,13 @@ routes = web.RouteTableDef()
|
|||||||
|
|
||||||
|
|
||||||
@routes.get("/")
|
@routes.get("/")
|
||||||
async def hello(request): # pylint: disable=unused-argument
|
async def hello(request: web.Request) -> web.Response: # pylint: disable=unused-argument
|
||||||
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): # pylint: disable=unused-argument
|
async def hello_json(request: web.Request) -> web.Response: # pylint: disable=unused-argument
|
||||||
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)
|
||||||
@ -31,7 +31,7 @@ async def hello_json(request): # pylint: disable=unused-argument
|
|||||||
app.add_routes(routes)
|
app.add_routes(routes)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main() -> None:
|
||||||
web.run_app(app, port=8080)
|
web.run_app(app, port=8080)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user