add kontor-blacksheep and kontor-piccolo as blueprints for new app
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3s
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import os
|
||||
|
||||
import jinja2
|
||||
from starlette.endpoints import HTTPEndpoint
|
||||
from starlette.responses import HTMLResponse
|
||||
|
||||
ENVIRONMENT = jinja2.Environment(
|
||||
loader=jinja2.FileSystemLoader(
|
||||
searchpath=os.path.join(os.path.dirname(__file__), "templates")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class HomeEndpoint(HTTPEndpoint):
|
||||
async def get(self, request):
|
||||
template = ENVIRONMENT.get_template("home.html.jinja")
|
||||
|
||||
content = template.render(
|
||||
title="Piccolo + ASGI",
|
||||
)
|
||||
|
||||
return HTMLResponse(content)
|
||||
@@ -0,0 +1,21 @@
|
||||
"""
|
||||
Import all of the Tables subclasses in your app here, and register them with
|
||||
the APP_CONFIG.
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from piccolo.conf.apps import AppConfig, table_finder
|
||||
|
||||
CURRENT_DIRECTORY = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
APP_CONFIG = AppConfig(
|
||||
app_name="home",
|
||||
migrations_folder_path=os.path.join(
|
||||
CURRENT_DIRECTORY, "piccolo_migrations"
|
||||
),
|
||||
table_classes=table_finder(modules=["home.tables"], exclude_imported=True),
|
||||
migration_dependencies=[],
|
||||
commands=[],
|
||||
)
|
||||
@@ -0,0 +1 @@
|
||||
Add migrations using `piccolo migrations new home --auto`.
|
||||
@@ -0,0 +1,11 @@
|
||||
from piccolo.table import Table
|
||||
from piccolo.columns import Varchar, Boolean
|
||||
|
||||
|
||||
class Task(Table):
|
||||
"""
|
||||
An example table.
|
||||
"""
|
||||
|
||||
name = Varchar()
|
||||
completed = Boolean(default=False)
|
||||
@@ -0,0 +1,16 @@
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>ASGI</title>
|
||||
<link rel="icon" href="/static/favicon.ico" />
|
||||
<link href="/static/main.css" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400;0,700;1,400&display=swap" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
{% block content %}{% endblock %}
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,86 @@
|
||||
{% extends "base.html.jinja" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="hero">
|
||||
<h1>{{ title }}</h1>
|
||||
</div>
|
||||
<div class="content">
|
||||
<section>
|
||||
<h2>Postgres</h2>
|
||||
<p>Make sure you create the database. See the <a href="https://piccolo-orm.readthedocs.io/en/latest/piccolo/getting_started/setup_postgres.html">docs</a> for guidance.</p>
|
||||
<p>See <code>piccolo_conf.py</code> for the database settings.</p>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Migrations</h2>
|
||||
<p>To use the admin, first run the migrations. This will create the user and session tables in the database:</p>
|
||||
<p class="code">
|
||||
<span>piccolo migrations forwards session_auth</span>
|
||||
<span>piccolo migrations forwards user</span>
|
||||
</p>
|
||||
<p>Then create a new user, making sure they're an admin.</p>
|
||||
<p class="code">
|
||||
<span>piccolo user create</span>
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Custom Tables</h2>
|
||||
<p>An example table called <code>Task</code> exists in <code>tables.py</code>.</p>
|
||||
<p>When you're ready, create a migration, and run it to add the table to the database:</p>
|
||||
<p class="code">
|
||||
<span>piccolo migrations new home --auto</span>
|
||||
<span>piccolo migrations forwards home</span>
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Try it out</h2>
|
||||
<h3>FastAPI</h3>
|
||||
<ul>
|
||||
<li><a href="/admin/">Admin</a></li>
|
||||
<li><a href="/docs/">Swagger API</a></li>
|
||||
</ul>
|
||||
<h3>Starlette</h3>
|
||||
<ul>
|
||||
<li><a href="/admin/">Admin</a></li>
|
||||
<li><a href="/tasks/">JSON endpoint</a></li>
|
||||
</ul>
|
||||
<h3>BlackSheep</h3>
|
||||
<ul>
|
||||
<li><a href="/admin/">Admin</a></li>
|
||||
<li><a href="/docs/">Swagger API</a></li>
|
||||
</ul>
|
||||
<h3>Litestar</h3>
|
||||
<ul>
|
||||
<li><a href="/admin/">Admin</a></li>
|
||||
<li><a href="/schema/swagger">Swagger API</a></li>
|
||||
</ul>
|
||||
<h3>Ravyn</h3>
|
||||
<ul>
|
||||
<li><a href="/admin/">Admin</a></li>
|
||||
<li><a href="/docs/swagger">Swagger API</a></li>
|
||||
</ul>
|
||||
<h3>Lilya</h3>
|
||||
<ul>
|
||||
<li><a href="/admin/">Admin</a></li>
|
||||
<li><a href="/tasks/">JSON endpoint</a></li>
|
||||
</ul>
|
||||
<h3>Quart</h3>
|
||||
<ul>
|
||||
<li><a href="/admin/">Admin</a></li>
|
||||
<li><a href="/docs">Swagger API</a></li>
|
||||
</ul>
|
||||
<h3>Falcon</h3>
|
||||
<ul>
|
||||
<li><a href="/admin/">Admin</a></li>
|
||||
<li><a href="/tasks/">JSON endpoint</a></li>
|
||||
</ul>
|
||||
<h3>Sanic</h3>
|
||||
<ul>
|
||||
<li><a href="/admin/">Admin</a></li>
|
||||
<li><a href="/docs/swagger">Swagger API</a></li>
|
||||
</ul>
|
||||
</section>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
Reference in New Issue
Block a user