From 3d6ba49607f7190006faec1954f5b46d49d1a36f Mon Sep 17 00:00:00 2001 From: sinisaos Date: Fri, 16 Aug 2024 09:39:24 +0200 Subject: [PATCH] granian support in asgi templates --- piccolo/apps/asgi/commands/new.py | 4 ++-- piccolo/apps/asgi/commands/templates/app/main.py.jinja | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/piccolo/apps/asgi/commands/new.py b/piccolo/apps/asgi/commands/new.py index 83d343c40..746c5db9a 100644 --- a/piccolo/apps/asgi/commands/new.py +++ b/piccolo/apps/asgi/commands/new.py @@ -9,10 +9,10 @@ from jinja2 import Environment, FileSystemLoader TEMPLATE_DIR = os.path.join(os.path.dirname(__file__), "templates/app/") -SERVERS = ["uvicorn", "Hypercorn"] +SERVERS = ["uvicorn", "Hypercorn", "granian"] ROUTER_DEPENDENCIES = { "starlette": ["starlette"], - "fastapi": ["fastapi>=0.100.0"], + "fastapi": ["fastapi>=0.112.1"], "blacksheep": ["blacksheep"], "litestar": ["litestar"], "esmerald": ["esmerald"], diff --git a/piccolo/apps/asgi/commands/templates/app/main.py.jinja b/piccolo/apps/asgi/commands/templates/app/main.py.jinja index 8fb934fbb..f3a0ce3ef 100644 --- a/piccolo/apps/asgi/commands/templates/app/main.py.jinja +++ b/piccolo/apps/asgi/commands/templates/app/main.py.jinja @@ -18,4 +18,8 @@ if __name__ == "__main__": asyncio.run(serve(app, CustomConfig())) serve(app) + {% elif server == 'granian' %} + import granian + + granian.Granian("app:app", interface="asgi").serve() {% endif %}