Skip to content

Commit 9d4ef06

Browse files
committed
improved asgi template - added 'try it out' links
1 parent 00eba40 commit 9d4ef06

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

piccolo/apps/asgi/commands/templates/starlette/_starlette_app.py.jinja

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
from piccolo_admin.endpoints import create_admin
2+
from piccolo_api.crud.endpoints import PiccoloCRUD
23
from piccolo.engine import engine_finder
34
from starlette.routing import Route, Mount
45
from starlette.applications import Starlette
56
from starlette.staticfiles import StaticFiles
67

78
from home.endpoints import HomeEndpoint
89
from home.piccolo_app import APP_CONFIG
10+
from home.tables import Task
911

1012

1113
app = Starlette(
1214
routes=[
1315
Route("/", HomeEndpoint),
1416
Mount("/admin/", create_admin(tables=APP_CONFIG.table_classes)),
1517
Mount("/static/", StaticFiles(directory="static")),
18+
Mount("/tasks/", PiccoloCRUD(table=Task))
1619
],
1720
)
1821

piccolo/apps/asgi/commands/templates/starlette/home/templates/home.html.jinja_raw

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<section>
1515
<h2>Migrations</h2>
16-
<p>To use the admin, first run the migrations.</p>
16+
<p>To use the admin, first run the migrations. This will create the user and session tables in the database:</p>
1717
<p class="code">
1818
<span>piccolo migrations forwards session_auth</span>
1919
<span>piccolo migrations forwards user</span>
@@ -25,13 +25,27 @@
2525
</section>
2626

2727
<section>
28-
<h2>Next Steps</h2>
29-
<p>Add some tables to <em>tables.py</em>.</p>
30-
<p>When you're ready to create migrations:</p>
28+
<h2>Custom Tables</h2>
29+
<p>An example table called <em>Task</em> exists in <em>tables.py</em>.</p>
30+
<p>When you're ready, create a migration, and run it to add the table to the database:</p>
3131
<p class="code">
3232
<span>piccolo migrations new home --auto</span>
3333
<span>piccolo migrations forwards home</span>
3434
</p>
3535
</section>
36+
37+
<section>
38+
<h2>Try it out</h2>
39+
<h3>FastAPI</h3>
40+
<ul>
41+
<li><a href="/admin/">Admin</a></li>
42+
<li><a href="/docs/">Swagger API</a></li>
43+
</ul>
44+
<h3>Starlette</h3>
45+
<ul>
46+
<li><a href="/admin/">Admin</a></li>
47+
<li><a href="/tasks/">JSON endpoint</a></li>
48+
</ul>
49+
</section>
3650
</div>
3751
{% endblock content %}

piccolo/apps/asgi/commands/templates/starlette/static/main.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ div.hero {
1414
padding: 5rem;
1515
}
1616

17+
a {
18+
color: #4C89C8;
19+
}
20+
1721
div.hero h1 {
1822
color: white;
1923
font-weight: normal;

0 commit comments

Comments
 (0)