Enable features later¶
Pyron is layered. You can start with an API and add the admin panel without rewriting handlers.
pyron init shop --template api
# … ship JSON for months …
cd shop
pyron enable admin
pyron createsuperuser
What pyron enable admin does:
- Creates
app/admin.pyfrom your SQLModel tables (skipped if the file exists — your edits stay). - If
main.pyalready hasadmin=Trueorapp.enable("admin", it stops. - Otherwise it appends a block wrapped in
# --- pyron enable admin ---.
The health endpoint you wrote yesterday is still there, byte-for-byte.
In code:
That also registers Pages and Settings. Operators add About / Contact in /admin; Jinja2 renders them at /p/{slug}. Site name, phone, and hours live under Settings. To skip Pages: app.enable("admin", engine=engine, pages=False) or Pyron(admin=True, pages=False).
app.enable("unknown") raises ValueError. Known: admin, mongo, redis.