File tree Expand file tree Collapse file tree 3 files changed +77
-1
lines changed
Expand file tree Collapse file tree 3 files changed +77
-1
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ def scaffold_frontend( # noqa: PLR0915
5454 project_root = Path .cwd ()
5555
5656 # Copy configuration files to project root
57- config_files = ["package.json" , "vite.config.js" , ".gitignore" ]
57+ config_files = ["package.json" , "vite.config.js" , ".gitignore" , "app.py" ]
5858 for file_name in config_files :
5959 src = stubs_path_resolved / file_name
6060 dest = project_root / file_name
Original file line number Diff line number Diff line change 1+ """
2+ Basic myfy app with frontend module.
3+
4+ This example demonstrates:
5+ - Server-side rendering with Jinja2
6+ - DaisyUI 5 components
7+ - Tailwind 4 styling
8+ """
9+
10+ from starlette .requests import Request
11+ from starlette .templating import Jinja2Templates
12+
13+ from myfy .core import Application
14+ from myfy .frontend import FrontendModule , render_template
15+ from myfy .web import WebModule , route
16+
17+
18+ @route .get ("/" )
19+ async def home (request : Request , templates : Jinja2Templates ):
20+ """Home page."""
21+ return render_template (
22+ "home.html" ,
23+ request = request ,
24+ templates = templates ,
25+ title = "Welcome to myfy" ,
26+ )
27+
28+
29+ # Create application
30+ app = Application (auto_discover = False )
31+ app .add_module (WebModule ())
32+ app .add_module (FrontendModule ())
33+
34+ if __name__ == "__main__" :
35+ import asyncio
36+
37+ asyncio .run (app .run ())
Original file line number Diff line number Diff line change 1+ {% extends "base.html" %}
2+
3+ {% block title %}{{ title }}{% endblock %}
4+
5+ {% block content %}
6+ < div class ="min-h-screen flex items-center justify-center bg-base-200 ">
7+ < div class ="text-center ">
8+ < h1 class ="text-5xl font-bold mb-4 ">
9+ Welcome to < span class ="text-primary "> myfy</ span >
10+ </ h1 >
11+ < p class ="text-xl mb-8 ">
12+ Your frontend is ready with Tailwind 4 and DaisyUI 5
13+ </ p >
14+
15+ < div class ="flex gap-4 justify-center ">
16+ < button class ="btn btn-primary "> Get Started</ button >
17+ < button class ="btn btn-outline "> Learn More</ button >
18+ </ div >
19+
20+ < div class ="mt-12 p-6 bg-base-100 rounded-lg shadow-lg max-w-2xl ">
21+ < h2 class ="text-2xl font-semibold mb-4 "> Next Steps</ h2 >
22+ < div class ="text-left space-y-2 ">
23+ < p class ="flex items-start gap-2 ">
24+ < span class ="text-primary "> ✓</ span >
25+ < span > Edit < code class ="text-sm bg-base-200 px-2 py-1 rounded "> frontend/templates/home.html</ code > to customize this page</ span >
26+ </ p >
27+ < p class ="flex items-start gap-2 ">
28+ < span class ="text-primary "> ✓</ span >
29+ < span > Add routes in < code class ="text-sm bg-base-200 px-2 py-1 rounded "> app.py</ code > </ span >
30+ </ p >
31+ < p class ="flex items-start gap-2 ">
32+ < span class ="text-primary "> ✓</ span >
33+ < span > Style with Tailwind classes and DaisyUI components</ span >
34+ </ p >
35+ </ div >
36+ </ div >
37+ </ div >
38+ </ div >
39+ {% endblock %}
You can’t perform that action at this time.
0 commit comments