fymo 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fymo-0.1.0/.gitignore +13 -0
- fymo-0.1.0/LICENSE +21 -0
- fymo-0.1.0/PKG-INFO +181 -0
- fymo-0.1.0/README.md +153 -0
- fymo-0.1.0/examples/todo_app/README.md +135 -0
- fymo-0.1.0/fymo/__init__.py +18 -0
- fymo-0.1.0/fymo/__version__.py +5 -0
- fymo-0.1.0/fymo/bundler/js/dist/runtime-metadata.json +5 -0
- fymo-0.1.0/fymo/bundler/js/dist/svelte-runtime.js +8975 -0
- fymo-0.1.0/fymo/bundler/js/dist/svelte-server-runtime.js +4188 -0
- fymo-0.1.0/fymo/cli/__init__.py +1 -0
- fymo-0.1.0/fymo/cli/commands/__init__.py +1 -0
- fymo-0.1.0/fymo/cli/commands/build.py +28 -0
- fymo-0.1.0/fymo/cli/commands/dev.py +59 -0
- fymo-0.1.0/fymo/cli/commands/init.py +41 -0
- fymo-0.1.0/fymo/cli/commands/new.py +294 -0
- fymo-0.1.0/fymo/cli/commands/serve.py +78 -0
- fymo-0.1.0/fymo/cli/main.py +89 -0
- fymo-0.1.0/fymo/core/__init__.py +29 -0
- fymo-0.1.0/fymo/core/assets.py +127 -0
- fymo-0.1.0/fymo/core/config.py +58 -0
- fymo-0.1.0/fymo/core/exceptions.py +49 -0
- fymo-0.1.0/fymo/core/html.py +89 -0
- fymo-0.1.0/fymo/core/manifest_cache.py +62 -0
- fymo-0.1.0/fymo/core/router.py +221 -0
- fymo-0.1.0/fymo/core/server.py +205 -0
- fymo-0.1.0/fymo/core/sidecar.py +100 -0
- fymo-0.1.0/fymo/core/template_renderer.py +262 -0
- fymo-0.1.0/fymo/remote/__init__.py +9 -0
- fymo-0.1.0/fymo/remote/adapters.py +114 -0
- fymo-0.1.0/fymo/remote/codegen.py +117 -0
- fymo-0.1.0/fymo/remote/context.py +50 -0
- fymo-0.1.0/fymo/remote/devalue.py +230 -0
- fymo-0.1.0/fymo/remote/discovery.py +109 -0
- fymo-0.1.0/fymo/remote/errors.py +34 -0
- fymo-0.1.0/fymo/remote/identity.py +43 -0
- fymo-0.1.0/fymo/remote/router.py +164 -0
- fymo-0.1.0/fymo/remote/typemap.py +190 -0
- fymo-0.1.0/fymo/utils/__init__.py +5 -0
- fymo-0.1.0/fymo/utils/colors.py +63 -0
- fymo-0.1.0/pyproject.toml +76 -0
- fymo-0.1.0/tests/__init__.py +0 -0
- fymo-0.1.0/tests/conftest.py +50 -0
- fymo-0.1.0/tests/core/__init__.py +0 -0
- fymo-0.1.0/tests/core/test_html.py +94 -0
- fymo-0.1.0/tests/core/test_manifest_cache.py +44 -0
- fymo-0.1.0/tests/core/test_sidecar.py +58 -0
- fymo-0.1.0/tests/integration/__init__.py +0 -0
- fymo-0.1.0/tests/integration/test_blog_e2e.py +167 -0
- fymo-0.1.0/tests/integration/test_cli_build.py +18 -0
- fymo-0.1.0/tests/integration/test_dev_watcher.py +46 -0
- fymo-0.1.0/tests/integration/test_dist_serving.py +63 -0
- fymo-0.1.0/tests/integration/test_remote_codegen_e2e.py +38 -0
- fymo-0.1.0/tests/integration/test_remote_e2e.py +65 -0
- fymo-0.1.0/tests/integration/test_remote_import.py +39 -0
- fymo-0.1.0/tests/integration/test_request_flow.py +192 -0
- fymo-0.1.0/tests/integration/test_route_params.py +41 -0
- fymo-0.1.0/tests/remote/__init__.py +0 -0
- fymo-0.1.0/tests/remote/test_adapters.py +88 -0
- fymo-0.1.0/tests/remote/test_codegen.py +100 -0
- fymo-0.1.0/tests/remote/test_context.py +24 -0
- fymo-0.1.0/tests/remote/test_devalue.py +241 -0
- fymo-0.1.0/tests/remote/test_discovery.py +135 -0
- fymo-0.1.0/tests/remote/test_errors.py +25 -0
- fymo-0.1.0/tests/remote/test_identity.py +33 -0
- fymo-0.1.0/tests/remote/test_router.py +143 -0
- fymo-0.1.0/tests/remote/test_typemap.py +169 -0
fymo-0.1.0/.gitignore
ADDED
fymo-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bishwas Bhandari and Fymo contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
fymo-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fymo
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SSR framework for Svelte 5 — esbuild pipeline, Node sidecar, SvelteKit-style remote functions
|
|
5
|
+
Project-URL: Homepage, https://github.com/Bishwas-py/fymo
|
|
6
|
+
Project-URL: Repository, https://github.com/Bishwas-py/fymo
|
|
7
|
+
Project-URL: Issues, https://github.com/Bishwas-py/fymo/issues
|
|
8
|
+
Author-email: Bishwas Bhandari <bishwasbh@gmail.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: esbuild,framework,python,ssr,svelte,wsgi
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Application
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Requires-Dist: click>=8.0.0
|
|
23
|
+
Requires-Dist: gunicorn>=23.0.0
|
|
24
|
+
Requires-Dist: pyyaml>=6.0
|
|
25
|
+
Provides-Extra: pydantic
|
|
26
|
+
Requires-Dist: pydantic>=2.5; extra == 'pydantic'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# Fymo Framework
|
|
30
|
+
|
|
31
|
+
<div align="center">
|
|
32
|
+
<h3>Production-ready Python SSR Framework for Svelte 5</h3>
|
|
33
|
+
<p>Build modern web applications with Python backend and Svelte 5 frontend</p>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
- **Build-time esbuild pipeline** — components compiled to hashed `dist/client/*.js` once, served as cacheable static assets.
|
|
39
|
+
- **Cross-route shared chunks** — packages imported by multiple pages (e.g. `date-fns`) are bundled once and shared.
|
|
40
|
+
- **Persistent Node sidecar SSR** — Python WSGI app talks to a long-lived Node process over stdio JSON; the sidecar imports prebuilt SSR modules and renders per request in microseconds.
|
|
41
|
+
- **Minimal HTML response** — typical page is < 10 KB; bundles loaded via `<link rel="modulepreload">` + `<script type="module" src=...>`.
|
|
42
|
+
- **`fymo dev` watcher** — incremental rebuilds on save with SSE-driven browser reload.
|
|
43
|
+
- **Any npm library** — Node SSR has full Node API surface (`fs`, `fetch`, `Buffer`, streams).
|
|
44
|
+
- **Svelte 5 runes** — full `$state`, `$derived`, `$effect`, `$props` support.
|
|
45
|
+
|
|
46
|
+
## Quick Start
|
|
47
|
+
|
|
48
|
+
### Installation
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install fymo
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Create a New Project
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
fymo new my-app
|
|
58
|
+
cd my-app
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Install Dependencies
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pip install -r requirements.txt
|
|
65
|
+
npm install
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Build and Serve
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
fymo build # produces dist/ with hashed JS/CSS bundles
|
|
72
|
+
fymo serve # production-style WSGI server
|
|
73
|
+
|
|
74
|
+
# or, for development:
|
|
75
|
+
fymo dev # incremental rebuild + browser auto-reload
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Visit `http://127.0.0.1:8000`.
|
|
79
|
+
|
|
80
|
+
## Project Structure
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
my-app/
|
|
84
|
+
├── app/
|
|
85
|
+
│ ├── controllers/ # Python controllers
|
|
86
|
+
│ ├── templates/ # Svelte components
|
|
87
|
+
│ ├── models/ # Data models
|
|
88
|
+
│ └── static/ # Static assets
|
|
89
|
+
├── dist/ # Built output (generated by fymo build)
|
|
90
|
+
├── config/ # Configuration
|
|
91
|
+
├── fymo.yml # Project configuration
|
|
92
|
+
├── server.py # Entry point
|
|
93
|
+
└── requirements.txt # Python dependencies
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Example Component
|
|
97
|
+
|
|
98
|
+
```svelte
|
|
99
|
+
<!-- app/templates/home/index.svelte -->
|
|
100
|
+
<script>
|
|
101
|
+
let { title, message } = $props();
|
|
102
|
+
let count = $state(0);
|
|
103
|
+
|
|
104
|
+
function increment() {
|
|
105
|
+
count++;
|
|
106
|
+
}
|
|
107
|
+
</script>
|
|
108
|
+
|
|
109
|
+
<div>
|
|
110
|
+
<h1>{title}</h1>
|
|
111
|
+
<p>{message}</p>
|
|
112
|
+
<button onclick={increment}>
|
|
113
|
+
Count: {count}
|
|
114
|
+
</button>
|
|
115
|
+
</div>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
# app/controllers/home.py
|
|
120
|
+
def getContext():
|
|
121
|
+
return {
|
|
122
|
+
'title': 'Welcome to Fymo',
|
|
123
|
+
'message': 'Build amazing apps with Python and Svelte 5!'
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## CLI Commands
|
|
128
|
+
|
|
129
|
+
- `fymo new <project>` — Create a new project
|
|
130
|
+
- `fymo build` — Build for production (produces `dist/`)
|
|
131
|
+
- `fymo serve` — Serve a built project
|
|
132
|
+
- `fymo dev` — Dev server with file watcher and live reload
|
|
133
|
+
- `fymo generate <type> <name>` — Generate components/controllers
|
|
134
|
+
|
|
135
|
+
## Configuration
|
|
136
|
+
|
|
137
|
+
Configure your project in `fymo.yml`:
|
|
138
|
+
|
|
139
|
+
```yaml
|
|
140
|
+
name: my-app
|
|
141
|
+
version: 1.0.0
|
|
142
|
+
|
|
143
|
+
routes:
|
|
144
|
+
root: home.index
|
|
145
|
+
resources:
|
|
146
|
+
- posts
|
|
147
|
+
- users
|
|
148
|
+
|
|
149
|
+
server:
|
|
150
|
+
host: 127.0.0.1
|
|
151
|
+
port: 8000
|
|
152
|
+
reload: true
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Architecture
|
|
156
|
+
|
|
157
|
+
Fymo combines:
|
|
158
|
+
- **Python** for server-side logic and routing (WSGI)
|
|
159
|
+
- **Svelte 5** for reactive UI components
|
|
160
|
+
- **esbuild** for fast, incremental JS/CSS bundling at build time
|
|
161
|
+
- **Node.js sidecar** for server-side rendering via stdio JSON protocol
|
|
162
|
+
|
|
163
|
+
## Contributing
|
|
164
|
+
|
|
165
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
MIT License - see LICENSE file for details
|
|
170
|
+
|
|
171
|
+
## Acknowledgments
|
|
172
|
+
|
|
173
|
+
- Built with [Svelte 5](https://svelte.dev)
|
|
174
|
+
- Bundled with [esbuild](https://esbuild.github.io)
|
|
175
|
+
- Inspired by modern web frameworks
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
<div align="center">
|
|
180
|
+
<strong>Built with love by the Fymo Team</strong>
|
|
181
|
+
</div>
|
fymo-0.1.0/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Fymo Framework
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<h3>Production-ready Python SSR Framework for Svelte 5</h3>
|
|
5
|
+
<p>Build modern web applications with Python backend and Svelte 5 frontend</p>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **Build-time esbuild pipeline** — components compiled to hashed `dist/client/*.js` once, served as cacheable static assets.
|
|
11
|
+
- **Cross-route shared chunks** — packages imported by multiple pages (e.g. `date-fns`) are bundled once and shared.
|
|
12
|
+
- **Persistent Node sidecar SSR** — Python WSGI app talks to a long-lived Node process over stdio JSON; the sidecar imports prebuilt SSR modules and renders per request in microseconds.
|
|
13
|
+
- **Minimal HTML response** — typical page is < 10 KB; bundles loaded via `<link rel="modulepreload">` + `<script type="module" src=...>`.
|
|
14
|
+
- **`fymo dev` watcher** — incremental rebuilds on save with SSE-driven browser reload.
|
|
15
|
+
- **Any npm library** — Node SSR has full Node API surface (`fs`, `fetch`, `Buffer`, streams).
|
|
16
|
+
- **Svelte 5 runes** — full `$state`, `$derived`, `$effect`, `$props` support.
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
### Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install fymo
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Create a New Project
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
fymo new my-app
|
|
30
|
+
cd my-app
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Install Dependencies
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install -r requirements.txt
|
|
37
|
+
npm install
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Build and Serve
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
fymo build # produces dist/ with hashed JS/CSS bundles
|
|
44
|
+
fymo serve # production-style WSGI server
|
|
45
|
+
|
|
46
|
+
# or, for development:
|
|
47
|
+
fymo dev # incremental rebuild + browser auto-reload
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Visit `http://127.0.0.1:8000`.
|
|
51
|
+
|
|
52
|
+
## Project Structure
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
my-app/
|
|
56
|
+
├── app/
|
|
57
|
+
│ ├── controllers/ # Python controllers
|
|
58
|
+
│ ├── templates/ # Svelte components
|
|
59
|
+
│ ├── models/ # Data models
|
|
60
|
+
│ └── static/ # Static assets
|
|
61
|
+
├── dist/ # Built output (generated by fymo build)
|
|
62
|
+
├── config/ # Configuration
|
|
63
|
+
├── fymo.yml # Project configuration
|
|
64
|
+
├── server.py # Entry point
|
|
65
|
+
└── requirements.txt # Python dependencies
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Example Component
|
|
69
|
+
|
|
70
|
+
```svelte
|
|
71
|
+
<!-- app/templates/home/index.svelte -->
|
|
72
|
+
<script>
|
|
73
|
+
let { title, message } = $props();
|
|
74
|
+
let count = $state(0);
|
|
75
|
+
|
|
76
|
+
function increment() {
|
|
77
|
+
count++;
|
|
78
|
+
}
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<div>
|
|
82
|
+
<h1>{title}</h1>
|
|
83
|
+
<p>{message}</p>
|
|
84
|
+
<button onclick={increment}>
|
|
85
|
+
Count: {count}
|
|
86
|
+
</button>
|
|
87
|
+
</div>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
# app/controllers/home.py
|
|
92
|
+
def getContext():
|
|
93
|
+
return {
|
|
94
|
+
'title': 'Welcome to Fymo',
|
|
95
|
+
'message': 'Build amazing apps with Python and Svelte 5!'
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## CLI Commands
|
|
100
|
+
|
|
101
|
+
- `fymo new <project>` — Create a new project
|
|
102
|
+
- `fymo build` — Build for production (produces `dist/`)
|
|
103
|
+
- `fymo serve` — Serve a built project
|
|
104
|
+
- `fymo dev` — Dev server with file watcher and live reload
|
|
105
|
+
- `fymo generate <type> <name>` — Generate components/controllers
|
|
106
|
+
|
|
107
|
+
## Configuration
|
|
108
|
+
|
|
109
|
+
Configure your project in `fymo.yml`:
|
|
110
|
+
|
|
111
|
+
```yaml
|
|
112
|
+
name: my-app
|
|
113
|
+
version: 1.0.0
|
|
114
|
+
|
|
115
|
+
routes:
|
|
116
|
+
root: home.index
|
|
117
|
+
resources:
|
|
118
|
+
- posts
|
|
119
|
+
- users
|
|
120
|
+
|
|
121
|
+
server:
|
|
122
|
+
host: 127.0.0.1
|
|
123
|
+
port: 8000
|
|
124
|
+
reload: true
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Architecture
|
|
128
|
+
|
|
129
|
+
Fymo combines:
|
|
130
|
+
- **Python** for server-side logic and routing (WSGI)
|
|
131
|
+
- **Svelte 5** for reactive UI components
|
|
132
|
+
- **esbuild** for fast, incremental JS/CSS bundling at build time
|
|
133
|
+
- **Node.js sidecar** for server-side rendering via stdio JSON protocol
|
|
134
|
+
|
|
135
|
+
## Contributing
|
|
136
|
+
|
|
137
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
138
|
+
|
|
139
|
+
## License
|
|
140
|
+
|
|
141
|
+
MIT License - see LICENSE file for details
|
|
142
|
+
|
|
143
|
+
## Acknowledgments
|
|
144
|
+
|
|
145
|
+
- Built with [Svelte 5](https://svelte.dev)
|
|
146
|
+
- Bundled with [esbuild](https://esbuild.github.io)
|
|
147
|
+
- Inspired by modern web frameworks
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
<div align="center">
|
|
152
|
+
<strong>Built with love by the Fymo Team</strong>
|
|
153
|
+
</div>
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Todo App - Fymo Example
|
|
2
|
+
|
|
3
|
+
A fully functional todo application built with Fymo framework, demonstrating Python SSR with Svelte 5.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Add, complete, and delete todos
|
|
8
|
+
- Filter todos (All, Active, Completed)
|
|
9
|
+
- Server-side rendering with Python
|
|
10
|
+
- Client-side reactivity with Svelte 5 runes
|
|
11
|
+
- Beautiful UI inspired by TodoMVC
|
|
12
|
+
|
|
13
|
+
## Tech Stack
|
|
14
|
+
|
|
15
|
+
- **Backend**: Python with Fymo framework
|
|
16
|
+
- **Frontend**: Svelte 5 with runes (`$state`, `$derived`)
|
|
17
|
+
- **SSR**: Persistent Node sidecar over stdio JSON
|
|
18
|
+
- **Bundler**: esbuild (hashed JS/CSS bundles in `dist/`)
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
### 1. Install Dependencies
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install -r requirements.txt
|
|
26
|
+
npm install
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 2. Build
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
fymo build
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 3. Serve
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
fymo serve # production-like, port 8000
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Or, for development with auto-rebuild and browser reload:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
fymo dev
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Visit `http://127.0.0.1:8000` to see the app.
|
|
48
|
+
|
|
49
|
+
## Project Structure
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
todo_app/
|
|
53
|
+
├── app/
|
|
54
|
+
│ ├── controllers/
|
|
55
|
+
│ │ └── todos.py # Todo controller with initial data
|
|
56
|
+
│ ├── templates/
|
|
57
|
+
│ │ └── todos/
|
|
58
|
+
│ │ └── index.svelte # Todo app component
|
|
59
|
+
│ └── static/ # Static assets
|
|
60
|
+
├── dist/ # Built output (generated by fymo build)
|
|
61
|
+
├── config/
|
|
62
|
+
│ └── routes.py # Route configuration
|
|
63
|
+
├── fymo.yml # Project configuration
|
|
64
|
+
└── server.py # Entry point
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## How It Works
|
|
68
|
+
|
|
69
|
+
1. **Build**: `fymo build` compiles Svelte components with esbuild into hashed bundles in `dist/`
|
|
70
|
+
2. **Server-Side Rendering**: Python WSGI app sends render requests to a long-lived Node sidecar over stdio JSON; SSR output arrives in microseconds
|
|
71
|
+
3. **Hydration**: The prebuilt client bundle hydrates the SSR'd HTML in the browser
|
|
72
|
+
4. **Reactivity**: Uses Svelte 5's runes for reactive state management
|
|
73
|
+
|
|
74
|
+
## Key Code Examples
|
|
75
|
+
|
|
76
|
+
### Svelte 5 Runes in Action
|
|
77
|
+
|
|
78
|
+
```svelte
|
|
79
|
+
<script>
|
|
80
|
+
// Props from server
|
|
81
|
+
let { todos: initialTodos = [] } = $props();
|
|
82
|
+
|
|
83
|
+
// Reactive state
|
|
84
|
+
let todos = $state([...initialTodos]);
|
|
85
|
+
let filter = $state('all');
|
|
86
|
+
|
|
87
|
+
// Derived state
|
|
88
|
+
let filteredTodos = $derived(() => {
|
|
89
|
+
switch(filter) {
|
|
90
|
+
case 'active':
|
|
91
|
+
return todos.filter(t => !t.completed);
|
|
92
|
+
case 'completed':
|
|
93
|
+
return todos.filter(t => t.completed);
|
|
94
|
+
default:
|
|
95
|
+
return todos;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
</script>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Python Controller
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
# app/controllers/todos.py
|
|
105
|
+
def getContext():
|
|
106
|
+
return {
|
|
107
|
+
'todos': [
|
|
108
|
+
{'id': 1, 'text': 'Learn Fymo', 'completed': True},
|
|
109
|
+
{'id': 2, 'text': 'Build awesome apps', 'completed': False}
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Features Demonstrated
|
|
115
|
+
|
|
116
|
+
- **Svelte 5 Runes**: `$state`, `$derived`, `$props`
|
|
117
|
+
- **Event Handling**: Click, keyboard events
|
|
118
|
+
- **Conditional Rendering**: Dynamic UI based on state
|
|
119
|
+
- **List Rendering**: Efficient keyed each blocks
|
|
120
|
+
- **Component Styling**: Scoped and global styles
|
|
121
|
+
- **Server Data**: Initial data from Python backend
|
|
122
|
+
|
|
123
|
+
## Extending the App
|
|
124
|
+
|
|
125
|
+
To persist todos, you could:
|
|
126
|
+
|
|
127
|
+
1. Add a database (SQLite, PostgreSQL)
|
|
128
|
+
2. Create API endpoints for CRUD operations
|
|
129
|
+
3. Use Svelte stores for global state
|
|
130
|
+
4. Add user authentication
|
|
131
|
+
5. Implement localStorage for offline support
|
|
132
|
+
|
|
133
|
+
## License
|
|
134
|
+
|
|
135
|
+
MIT - Part of the Fymo framework examples
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Fymo - Production-ready Python SSR Framework for Svelte 5
|
|
3
|
+
|
|
4
|
+
A modern web framework that brings the power of Svelte 5 to Python backends,
|
|
5
|
+
enabling server-side rendering with full client-side hydration.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from fymo.core.server import create_app, FymoApp
|
|
9
|
+
|
|
10
|
+
__version__ = "0.1.0"
|
|
11
|
+
__author__ = "Fymo Contributors"
|
|
12
|
+
__license__ = "MIT"
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"create_app",
|
|
16
|
+
"FymoApp",
|
|
17
|
+
"__version__"
|
|
18
|
+
]
|