Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ASGI requirements #911

Merged
merged 5 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion piccolo/apps/asgi/commands/new.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@

TEMPLATE_DIR = os.path.join(os.path.dirname(__file__), "templates/app/")
SERVERS = ["uvicorn", "Hypercorn"]
ROUTERS = ["starlette", "fastapi", "blacksheep", "litestar", "esmerald"]
ROUTER_DEPENDENCIES = {
"starlette": ["starlette"],
"fastapi": ["fastapi>=0.100.0"],
"blacksheep": ["blacksheep"],
"litestar": ["litestar"],
"esmerald": ["esmerald"],
}
ROUTERS = list(ROUTER_DEPENDENCIES.keys())


def print_instruction(message: str):
Expand Down
11 changes: 10 additions & 1 deletion piccolo/apps/asgi/commands/templates/app/_esmerald_app.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ from pathlib import Path

from piccolo.utils.pydantic import create_pydantic_model
from piccolo.engine import engine_finder
from piccolo_admin.endpoints import create_admin

from esmerald import (
Esmerald,
Expand Down Expand Up @@ -92,7 +93,15 @@ class TaskAPIView(APIView):
app = Esmerald(
routes=[
Gateway("/", handler=home),
Gateway("/tasks", handler=TaskAPIView)
Gateway("/tasks", handler=TaskAPIView),
Include(
"/admin/",
create_admin(
tables=APP_CONFIG.table_classes,
# Required when running under HTTPS:
# allowed_hosts=['my_site.com']
),
),
],
static_files_config=StaticFilesConfig(path="/static", directory=Path("static")),
on_startup=[open_database_connection_pool],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
{{ router_dependency }}
{% endfor -%}
{{ server }}
jinja2
piccolo[postgres]
piccolo_admin
requests
piccolo[postgres]>=1.0.0
piccolo_admin>=1.0.0
Loading