You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use the recently added `allinone.py` which combines the content of 3 files into a single one that automatically builds the Javascript and launches the server. Just do `python allinone.py` instead of `python server.py`. Note that `allinone.py` will likely be the focus of future development and, hence, will continue to diverge from the behavior of `server.py + client.py + common.py`.
30
+
### NEW Single Source Files
31
+
Use the recently added `allinone.py` which combines the content of 3 files into a single one that automatically builds the Javascript and launches the server. Just do `python allinone.py` instead of `python server.py`. There are also two other new files, `minimal_allinone.py`and `serverless.py`. These files will likely be the focus of future development and, hence, will continue to diverge from the behavior of `server.py + client.py + common.py` which should now be considered deprecated, or at least discouraged.
32
32
33
33
### Installation and usage
34
34
```
@@ -49,7 +49,7 @@ Use the recently added `allinone.py` which combines the content of 3 files into
49
49

50
50
51
51
### Rapid development
52
-
*Saving a change to any source file triggers a rebuild and reload of the server and the client page. See [Auto Reload](doc/AutoReload.md) for details.
52
+
*While the app is running, saving a change to any source file triggers a rebuild and reload of the server and the client page. See [Auto Reload](doc/AutoReload.md) for details.
53
53
* Clean pythonic syntax for generating html. See [htmltree](https://github.com/Michael-F-Ellis/htmltree) docs for details. Here's the function that creates all the body html in the demo above.
54
54
```
55
55
def makeBody():
@@ -183,6 +183,20 @@ and here is the output `makeBody()` produces:
183
183
</div>
184
184
</div>
185
185
```
186
+
### Starting Smaller
187
+
If `allinone.py` is a least somewhat close to where you want to start with development, you can simply make a copy under a new names and start hacking, but you might find a better starting point for your development in one of the two additional skeleton files provided in the repo.
188
+
189
+
## minimal_allinone.py
190
+
This skeleton omits most of the content from allinone.py but retains the server instance, command line options and automatic reloading. The client-server state exchange is also kept but in very minimal form. The display is simply a headline with a counter updating once per second with a count supplied from the server.
191
+
192
+

193
+
194
+
195
+
## serverless.py
196
+
As the name implies, this skeleton has the server code removed. It's a once-through script that generates an index.html file and and a js file with Transcrypt. The script finishes by using Python's built-in web browser module to open the index file as a `file://` URL in your default web browser. When the index file loads it fetches and runs the JS. The display is identical in form to the one from `minimal_allinone.py` but the counter updating is handled locally in JS.
197
+
198
+

199
+
186
200
### Files
187
201
Here's what comes from the repository:
188
202
```
@@ -196,7 +210,9 @@ Here's what comes from the repository:
196
210
│ ├── example_wsgi.py
197
211
│ └── img
198
212
│ └── nppwad.gif
213
+
├── minimal_allinone.py.py
199
214
├── server.py (deprecated)
215
+
├── serverless.py
200
216
201
217
```
202
218
Ater running `allinone.py` for the first time, files are generated and the directory tree will look like:
@@ -221,16 +237,18 @@ Ater running `allinone.py` for the first time, files are generated and the direc
221
237
│ ├── example_wsgi.py
222
238
│ └── img
223
239
│ └── nppwad.gif
240
+
├── minimal_allinone.py.py
224
241
├── server.py
242
+
├── serverless.py
225
243
226
244
```
227
245
228
246
## Parting Thoughts
229
247
### The Bad News
230
-
While this approach can save you from the frustrations of dealing with .html, .css, and .js syntax, it can't save you from the need to *understand* the Document Object Model, browser events, ajax, http request routing, etc.
248
+
While this approach to development can save you from the frustrations of dealing with .html, .css, and .js syntax, it can't save you from the need to *understand* the Document Object Model, browser events, ajax, http request routing, etc.
231
249
232
250
### The Good News
233
-
If you're already comfortable in Python and understand what goes on in a browser and web server, you can use this skeleton as a starting point for developing entirely in Python.
251
+
If you're already comfortable in Python and understand what goes on in a browser and web server, you can use these skeletons as a starting point for developing entirely in Python.
0 commit comments