fastreact 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.
@@ -0,0 +1,211 @@
1
+ Metadata-Version: 2.4
2
+ Name: fastreact
3
+ Version: 0.1.0
4
+ Summary: FastAPI + React unified stack — zero config, one server, Python tracebacks in browser
5
+ Author-email: Mohammad Ramiz <your@email.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/RamizMohammad/fastreact
8
+ Project-URL: Issues, https://github.com/RamizMohammad/fastreact/issues
9
+ Project-URL: Portfolio, https://www.mohammadramiz.in
10
+ Project-URL: LinkedIn, https://www.linkedin.com/in/mohammad-ramiz
11
+ Project-URL: Source Code, https://github.com/RamizMohammad/fastreact
12
+ Keywords: fastapi,react,fullstack,vite,uvicorn,flask,spa,single-page-app,python,javascript
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Framework :: FastAPI
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Internet :: WWW/HTTP
23
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/markdown
26
+ Requires-Dist: fastapi>=0.100.0
27
+ Requires-Dist: uvicorn>=0.23.0
28
+ Requires-Dist: httpx>=0.24.0
29
+ Provides-Extra: flask
30
+ Requires-Dist: flask>=2.3.0; extra == "flask"
31
+ Provides-Extra: dev
32
+ Requires-Dist: pytest>=7.0; extra == "dev"
33
+ Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
34
+ Requires-Dist: httpx>=0.24.0; extra == "dev"
35
+
36
+ # ⚡ FastReact
37
+
38
+ > **FastAPI + React = One Unified Stack**
39
+ > Zero config. One server. Python tracebacks in your browser.
40
+
41
+ 📖 **[Full Usage Guide →](USAGE.md)**
42
+
43
+ ---
44
+
45
+ ## What is FastReact?
46
+
47
+ FastReact is a Python library that bridges **FastAPI** and **React** into a single seamless stack.
48
+
49
+ - 🐍 FastAPI thinks it's serving Jinja templates — it's actually serving React
50
+ - ⚡ React thinks it's a normal Vite app — it's tunneled through FastAPI
51
+ - 🔴 Python errors appear as beautiful overlays in the browser (just like React's own error screen)
52
+ - 🔒 Python is the gatekeeper — React can only visit routes you register
53
+ - 🚀 One `uvicorn` instance serves everything — in dev AND production
54
+
55
+ ---
56
+
57
+ ## Install
58
+
59
+ ```bash
60
+ # FastAPI + React
61
+ pip install fastreact
62
+
63
+ # Flask + React
64
+ pip install fastreact[flask]
65
+ ```
66
+
67
+ ---
68
+
69
+ ## Quick Start
70
+
71
+ ```bash
72
+ # 1. Scaffold React inside your FastAPI project
73
+ fastreact create frontend
74
+
75
+ # 2. Start both servers together with live request monitor
76
+ fastreact dev main:app --reload --call
77
+
78
+ # 3. Build for production
79
+ cd frontend && npm run build
80
+ uvicorn main:app --host 0.0.0.0 --port 8000
81
+ ```
82
+
83
+ ---
84
+
85
+ ## Usage
86
+
87
+ ```python
88
+ # main.py
89
+ from fastreact import FastReact
90
+
91
+ app = FastReact()
92
+
93
+ # React page routes — /api/ prefix — browser only
94
+ # Postman/curl → 405 Not Allowed
95
+ @app.get("/api/")
96
+ def home(): pass
97
+
98
+ @app.get("/api/users")
99
+ def users_page(): pass
100
+
101
+ # Normal data routes — everyone can call
102
+ @app.get("/users")
103
+ def get_users():
104
+ return {"users": ["Alice", "Bob"]}
105
+ ```
106
+
107
+ ```bash
108
+ uvicorn main:app --reload
109
+ ```
110
+
111
+ ---
112
+
113
+ ## Flask Support
114
+
115
+ ```python
116
+ from fastreact import FlaskReact
117
+
118
+ app = FlaskReact()
119
+
120
+ @app.route("/api/users")
121
+ def users_page(): pass
122
+
123
+ @app.route("/users")
124
+ def get_users():
125
+ return {"users": ["Alice", "Bob"]}
126
+
127
+ if __name__ == "__main__":
128
+ app.run()
129
+ ```
130
+
131
+ ---
132
+
133
+ ## Routing Rules
134
+
135
+ | Route | Browser | Postman/curl |
136
+ |-------|---------|--------------|
137
+ | `/api/users` (react prefix) | ✅ React renders | ❌ 405 Not Allowed |
138
+ | `/users` (normal route) | ✅ JSON | ✅ JSON |
139
+ | `/api/unknown` (unregistered) | ❌ 404 | ❌ 404 |
140
+
141
+ ### Custom prefix
142
+
143
+ ```python
144
+ app = FastReact(react_prefix="ui") # /ui/... becomes React routes
145
+ ```
146
+
147
+ ---
148
+
149
+ ## CLI
150
+
151
+ ```
152
+ fastreact create <n> Scaffold a new React (Vite) app
153
+ fastreact dev <file:app> [opts] Start FastAPI + React dev servers together
154
+
155
+ --reload Auto-restart on file save
156
+ --port <number> Port number default: 8000
157
+ --host <address> Host address default: 127.0.0.1
158
+ --call Live HTTP request monitor
159
+ ```
160
+
161
+ ---
162
+
163
+ ## Traceback Overlay
164
+
165
+ Python errors render as a beautiful browser overlay instead of JSON:
166
+
167
+ ```
168
+ 🔴 FastAPI Traceback — AttributeError
169
+ 'NoneType' object has no attribute 'id'
170
+
171
+ File main.py, line 24, in get_user
172
+ return user.id
173
+ ^^^^^^^^^^^^^^
174
+ ```
175
+
176
+ ---
177
+
178
+ ## Roadmap
179
+
180
+ - [x] FastAPI + React unified stack
181
+ - [x] Flask + React support
182
+ - [x] CLI dev mode — one command starts everything
183
+ - [x] Live request monitor (`--call`)
184
+ - [x] Python traceback overlay in browser
185
+ - [x] Route protection — browser-only React routes
186
+ - [x] Auto path normalization
187
+ - [ ] `--globalname` — instant public URL via SSH tunnel (v0.2.0)
188
+
189
+ ---
190
+
191
+ ## Documentation
192
+
193
+ | Guide | Description |
194
+ |-------|-------------|
195
+ | [USAGE.md](USAGE.md) | Full usage guide with all examples |
196
+ | [PUBLISH.md](PUBLISH.md) | How to publish to PyPI |
197
+
198
+ ---
199
+
200
+ ## Author
201
+
202
+ **Mohammad Ramiz**
203
+ - 🌐 [mohammadramiz.in](https://www.mohammadramiz.in)
204
+ - 💼 [LinkedIn](https://www.linkedin.com/in/mohammad-ramiz)
205
+ - 🐙 [GitHub](https://github.com/RamizMohammad)
206
+
207
+ ---
208
+
209
+ ## License
210
+
211
+ MIT
@@ -0,0 +1,176 @@
1
+ # ⚡ FastReact
2
+
3
+ > **FastAPI + React = One Unified Stack**
4
+ > Zero config. One server. Python tracebacks in your browser.
5
+
6
+ 📖 **[Full Usage Guide →](USAGE.md)**
7
+
8
+ ---
9
+
10
+ ## What is FastReact?
11
+
12
+ FastReact is a Python library that bridges **FastAPI** and **React** into a single seamless stack.
13
+
14
+ - 🐍 FastAPI thinks it's serving Jinja templates — it's actually serving React
15
+ - ⚡ React thinks it's a normal Vite app — it's tunneled through FastAPI
16
+ - 🔴 Python errors appear as beautiful overlays in the browser (just like React's own error screen)
17
+ - 🔒 Python is the gatekeeper — React can only visit routes you register
18
+ - 🚀 One `uvicorn` instance serves everything — in dev AND production
19
+
20
+ ---
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ # FastAPI + React
26
+ pip install fastreact
27
+
28
+ # Flask + React
29
+ pip install fastreact[flask]
30
+ ```
31
+
32
+ ---
33
+
34
+ ## Quick Start
35
+
36
+ ```bash
37
+ # 1. Scaffold React inside your FastAPI project
38
+ fastreact create frontend
39
+
40
+ # 2. Start both servers together with live request monitor
41
+ fastreact dev main:app --reload --call
42
+
43
+ # 3. Build for production
44
+ cd frontend && npm run build
45
+ uvicorn main:app --host 0.0.0.0 --port 8000
46
+ ```
47
+
48
+ ---
49
+
50
+ ## Usage
51
+
52
+ ```python
53
+ # main.py
54
+ from fastreact import FastReact
55
+
56
+ app = FastReact()
57
+
58
+ # React page routes — /api/ prefix — browser only
59
+ # Postman/curl → 405 Not Allowed
60
+ @app.get("/api/")
61
+ def home(): pass
62
+
63
+ @app.get("/api/users")
64
+ def users_page(): pass
65
+
66
+ # Normal data routes — everyone can call
67
+ @app.get("/users")
68
+ def get_users():
69
+ return {"users": ["Alice", "Bob"]}
70
+ ```
71
+
72
+ ```bash
73
+ uvicorn main:app --reload
74
+ ```
75
+
76
+ ---
77
+
78
+ ## Flask Support
79
+
80
+ ```python
81
+ from fastreact import FlaskReact
82
+
83
+ app = FlaskReact()
84
+
85
+ @app.route("/api/users")
86
+ def users_page(): pass
87
+
88
+ @app.route("/users")
89
+ def get_users():
90
+ return {"users": ["Alice", "Bob"]}
91
+
92
+ if __name__ == "__main__":
93
+ app.run()
94
+ ```
95
+
96
+ ---
97
+
98
+ ## Routing Rules
99
+
100
+ | Route | Browser | Postman/curl |
101
+ |-------|---------|--------------|
102
+ | `/api/users` (react prefix) | ✅ React renders | ❌ 405 Not Allowed |
103
+ | `/users` (normal route) | ✅ JSON | ✅ JSON |
104
+ | `/api/unknown` (unregistered) | ❌ 404 | ❌ 404 |
105
+
106
+ ### Custom prefix
107
+
108
+ ```python
109
+ app = FastReact(react_prefix="ui") # /ui/... becomes React routes
110
+ ```
111
+
112
+ ---
113
+
114
+ ## CLI
115
+
116
+ ```
117
+ fastreact create <n> Scaffold a new React (Vite) app
118
+ fastreact dev <file:app> [opts] Start FastAPI + React dev servers together
119
+
120
+ --reload Auto-restart on file save
121
+ --port <number> Port number default: 8000
122
+ --host <address> Host address default: 127.0.0.1
123
+ --call Live HTTP request monitor
124
+ ```
125
+
126
+ ---
127
+
128
+ ## Traceback Overlay
129
+
130
+ Python errors render as a beautiful browser overlay instead of JSON:
131
+
132
+ ```
133
+ 🔴 FastAPI Traceback — AttributeError
134
+ 'NoneType' object has no attribute 'id'
135
+
136
+ File main.py, line 24, in get_user
137
+ return user.id
138
+ ^^^^^^^^^^^^^^
139
+ ```
140
+
141
+ ---
142
+
143
+ ## Roadmap
144
+
145
+ - [x] FastAPI + React unified stack
146
+ - [x] Flask + React support
147
+ - [x] CLI dev mode — one command starts everything
148
+ - [x] Live request monitor (`--call`)
149
+ - [x] Python traceback overlay in browser
150
+ - [x] Route protection — browser-only React routes
151
+ - [x] Auto path normalization
152
+ - [ ] `--globalname` — instant public URL via SSH tunnel (v0.2.0)
153
+
154
+ ---
155
+
156
+ ## Documentation
157
+
158
+ | Guide | Description |
159
+ |-------|-------------|
160
+ | [USAGE.md](USAGE.md) | Full usage guide with all examples |
161
+ | [PUBLISH.md](PUBLISH.md) | How to publish to PyPI |
162
+
163
+ ---
164
+
165
+ ## Author
166
+
167
+ **Mohammad Ramiz**
168
+ - 🌐 [mohammadramiz.in](https://www.mohammadramiz.in)
169
+ - 💼 [LinkedIn](https://www.linkedin.com/in/mohammad-ramiz)
170
+ - 🐙 [GitHub](https://github.com/RamizMohammad)
171
+
172
+ ---
173
+
174
+ ## License
175
+
176
+ MIT
@@ -0,0 +1,15 @@
1
+ from .core import FastReact
2
+
3
+ __version__ = "0.1.0"
4
+ __all__ = ["FastReact", "FlaskReact"]
5
+
6
+
7
+ def __getattr__(name):
8
+ """
9
+ Lazy import FlaskReact only when explicitly requested.
10
+ This prevents Flask import errors for users who only use FastReact.
11
+ """
12
+ if name == "FlaskReact":
13
+ from .flask_core import FlaskReact
14
+ return FlaskReact
15
+ raise AttributeError(f"module 'fastreact' has no attribute {name!r}")