webdev 2.0.0__py3-none-any.whl → 2.1.0__py3-none-any.whl

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.
webdev/__init__.py CHANGED
@@ -25,6 +25,6 @@ index, optional HTTPS, and more.
25
25
 
26
26
  from __future__ import annotations
27
27
 
28
- __version__ = '2.0.0'
28
+ __version__ = '2.1.0'
29
29
 
30
30
  __all__ = ['__version__']
webdev/static.py CHANGED
@@ -50,6 +50,13 @@ EXTRA_MIME_TYPES = {
50
50
  '.svelte': 'text/plain',
51
51
  '.yml': 'text/plain',
52
52
  '.yaml': 'text/plain',
53
+ '.template': 'text/plain',
54
+ '.tmpl': 'text/plain',
55
+ '.tpl': 'text/plain',
56
+ '.j2': 'text/plain',
57
+ '.jinja': 'text/plain',
58
+ '.jinja2': 'text/plain',
59
+ '.config': 'text/plain',
53
60
  }
54
61
 
55
62
  #: Number of bytes inspected when sniffing whether an unknown file is text.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: webdev
3
- Version: 2.0.0
3
+ Version: 2.1.0
4
4
  Summary: Small, fast development web server with a modern dark directory index
5
5
  Project-URL: Homepage, https://github.com/kuralabs/webdev
6
6
  Project-URL: Repository, https://github.com/kuralabs/webdev
@@ -32,49 +32,77 @@ Description-Content-Type: text/x-rst
32
32
  Development Web Server
33
33
  ======================
34
34
 
35
- About
36
- =====
37
-
38
- ``webdev`` is a small, fast development web server. It serves any local
39
- directory over HTTP (or HTTPS) with developer-friendly conveniences, and ships
40
- a modern, dark-themed directory index.
35
+ ``webdev`` is a **small, fast local development web server**. Point it at a
36
+ folder and it serves it over HTTP (or HTTPS) with developer-friendly
37
+ conveniences and a modern, dark-themed directory index.
41
38
 
42
39
  It is built on `Starlette <https://www.starlette.io/>`_ and
43
- `Uvicorn <https://www.uvicorn.org/>`_ (an ASGI stack), and requires Python 3.10+.
40
+ `Uvicorn <https://www.uvicorn.org/>`_ (an async ASGI stack) and requires
41
+ **Python 3.10+**.
44
42
 
45
- Features
46
- ========
43
+ Quick start
44
+ ===========
47
45
 
48
- - **Serve any directory** — passed as the first positional argument; defaults to
49
- the current directory.
50
- - **Graceful when the folder disappears** — responds with ``404`` instead of
51
- crashing if the served directory is removed, and **recovers automatically**
52
- the moment it is recreated. Paths are resolved against the live filesystem on
53
- every request, which is great with build systems that perform clean/rebuild
54
- actions.
55
- - **Automatic port selection** — if the base port is busy, the next free port in
56
- a range is used. Can be forced to a single port.
57
- - **Serve a not-yet-existing folder** — ``--future`` assumes the folder will be
58
- created later.
59
- - **Modern dark directory index** — breadcrumbs, file-type icons, human-readable
60
- sizes, modified dates and client-side sortable columns. Themable: drop a new
61
- directory under ``webdev/templates/<theme>/``.
62
- - **Live reload** — connected browsers refresh automatically on file changes
63
- (via a WebSocket; a tiny auto-reconnecting snippet is injected into HTML).
64
- - **No-cache headers** for always-fresh development content.
65
- - **SPA fallback** — optionally serve ``index.html`` for unknown routes.
66
- - **Gzip**, **CORS**, optional **HTTPS** (self-signed if no cert/key is given),
67
- and a startup **QR code / LAN URL** for quick mobile testing.
68
- - **Config file** — every option can be set via ``webdev.toml`` (or a
69
- ``[tool.webdev]`` table). Precedence: CLI flag > config file > default.
46
+ ::
47
+
48
+ # Install (see more options below)
49
+ uv tool install webdev
50
+
51
+ # Serve the current directory on http://localhost:8080
52
+ webdev
53
+
54
+ # Serve a specific folder
55
+ webdev ./public
56
+
57
+ # See every option
58
+ webdev --help
70
59
 
71
60
  Installation
72
61
  ============
73
62
 
74
- ::
63
+ With `uv <https://docs.astral.sh/uv/>`_ (recommended)::
64
+
65
+ uv tool install webdev
66
+
67
+ With `pipx <https://pipx.pypa.io/>`_::
68
+
69
+ pipx install webdev
70
+
71
+ Or with plain ``pip`` into an environment of your choice::
75
72
 
76
73
  pip install webdev
77
74
 
75
+ Features
76
+ ========
77
+
78
+ - 🗂️ **Serve any directory** — passed as the first positional argument; defaults
79
+ to the current directory.
80
+ - 🩹 **Graceful when the folder disappears** — responds with ``404`` instead of
81
+ crashing if the served directory is removed, and **recovers automatically**
82
+ the moment it is recreated. Paths are resolved against the live filesystem on
83
+ every request — ideal for build systems that clean and rebuild output.
84
+ - 🔀 **Automatic port selection** — if the base port is busy, the next free port
85
+ in a range is used. Can be forced to a single exact port.
86
+ - 🔮 **Serve a not-yet-existing folder** — ``--future`` assumes the folder will
87
+ be created later.
88
+ - 🎨 **Modern dark directory index** — breadcrumbs, file-type icons,
89
+ human-readable sizes, modified dates and client-side sortable columns.
90
+ **Themable**: drop a new directory under ``webdev/templates/<theme>/``.
91
+ - 🔁 **Live reload** — connected browsers refresh automatically on file changes
92
+ (via a WebSocket; a tiny auto-reconnecting snippet is injected into HTML).
93
+ - 📱 **Instant mobile testing** — a **QR code and LAN URL** are printed at
94
+ startup so you can open the site on your phone.
95
+ - 🌈 **Colorized, level-aware logs** for readable output.
96
+ - ⚡ **No-cache headers** for always-fresh development content.
97
+ - 👀 **Previews text inline** — plain-text, config and template files (``.txt``,
98
+ ``.json``, ``.yaml``, ``.ini``, ``.toml``, ``.j2``/``.jinja2``, ``.template``,
99
+ ``.config`` and more) open in the browser instead of being downloaded.
100
+ - 🧭 **SPA fallback** — optionally serve ``index.html`` for unknown routes.
101
+ - 📦 **Gzip**, **CORS** and optional **HTTPS** (self-signed if no cert/key is
102
+ given).
103
+ - ⚙️ **Config file** — every option can be set via ``webdev.toml`` (or a
104
+ ``[tool.webdev]`` table). Precedence: CLI flag > config file > default.
105
+
78
106
  Usage
79
107
  =====
80
108
 
@@ -100,6 +128,9 @@ Examples::
100
128
  # Single-page app: fall back to index.html for client-side routes
101
129
  webdev --spa ./dist
102
130
 
131
+ # Serve a build output folder that does not exist yet
132
+ webdev --future ./dist
133
+
103
134
  Options and config keys
104
135
  -----------------------
105
136
 
@@ -125,30 +156,19 @@ Colorized logs ``--color/--no-color`` ``color`` enabled
125
156
  HTTPS/TLS ``--https/--no-https`` ``https`` disabled
126
157
  TLS cert / key ``--cert`` / ``--key`` ``cert`` / ``key`` self-signed
127
158
  Index theme ``--theme`` ``theme`` dark
159
+ Verbosity ``-v`` (repeatable) ``verbose`` 0
128
160
  ===================== ======================== ================== ==========
129
161
 
130
- Example ``webdev.toml``::
162
+ Commit a ``webdev.toml`` next to your project to share settings with your team.
163
+ Any option works as a flat key, or under a ``[tool.webdev]`` table (handy inside
164
+ a ``pyproject.toml``)::
131
165
 
166
+ # webdev.toml
132
167
  port = 3000
133
168
  force_port = true
134
169
  spa = true
135
170
  cors = true
136
171
 
137
- Design notes
138
- ============
139
-
140
- - **Framework:** Starlette + Uvicorn was chosen over a full framework such as
141
- Sanic because this is a static file server: Starlette provides exactly the
142
- primitives needed (routing, static serving, WebSockets, middleware) with a
143
- small surface, and Uvicorn handles fast binding, HTTP keep-alive, HTTPS and
144
- graceful shutdown.
145
- - **The legacy reload hack is gone.** The old server patched ``send_head`` to
146
- ``chdir`` back into the served folder; modern ``http.server`` captures the
147
- working directory in the handler constructor, so that hook stopped running and
148
- a removed folder crashed the request. ``webdev`` now resolves every request
149
- against the live filesystem, so missing folders yield a real ``404`` and
150
- recover automatically.
151
-
152
172
  Development
153
173
  ===========
154
174
 
@@ -165,12 +185,32 @@ only tool you need preinstalled::
165
185
  # Build and verify the distribution
166
186
  tox -e build
167
187
 
188
+ # Build, install in a throwaway venv and run (pass args after --)
189
+ tox -e run -- -p 3000 ./public
190
+
168
191
  Each environment declares its own tooling dependencies in ``tox.ini`` so it
169
192
  installs only what it needs.
170
193
 
171
194
  Changelog
172
195
  =========
173
196
 
197
+ 2.1.0
198
+ -----
199
+
200
+ **New**
201
+
202
+ - Plain-text, config and template files (such as ``.yaml``, ``.tpl``, ``.j2``,
203
+ ``.jinja2``, ``.template`` and ``.config``) now open inline in the browser
204
+ instead of being downloaded (issue #8). Thanks to zaro0508 for the report.
205
+
206
+ 2.0.1
207
+ -----
208
+
209
+ **Changed**
210
+
211
+ - Modernized and expanded the README (uv-first installation, refreshed feature
212
+ overview and usage).
213
+
174
214
  2.0.0
175
215
  -----
176
216
 
@@ -224,7 +264,8 @@ License
224
264
 
225
265
  ::
226
266
 
227
- Copyright (C) 2015-2026 Carlos Jenkins <carlos@jenkins.co.cr>
267
+ Copyright (C) 2026 KuraLabs S.R.L <info@kuralabs.io>
268
+ Copyright (C) 2015-2016 Carlos Jenkins <carlos@jenkins.co.cr>
228
269
 
229
270
  Licensed under the Apache License, Version 2.0 (the "License");
230
271
  you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- webdev/__init__.py,sha256=OkpQaCR6ZuY8wFMFvnDBeaRAXPX_rWu4aqlbRkxoi_U,1064
1
+ webdev/__init__.py,sha256=gaZzbl0gsnC8zLnwpR8KOCeQnE3u9S32WqoUnBhOM04,1064
2
2
  webdev/__main__.py,sha256=RhmDml_ICjjb3Ny0LDjH2HaIN2X0jGtzjwXBqPvsbwA,945
3
3
  webdev/cli.py,sha256=GtZejOzYo8F5R1e8Hw8M3hoAcVHOEZbiFJcTJloFbM4,10504
4
4
  webdev/config.py,sha256=4n4GnJHGCNBUV6Jsg4uEH9KGQJxr-CO9UkqkjHVEra4,6537
@@ -7,14 +7,14 @@ webdev/livereload.py,sha256=zghIaJUAWAdSPyWpGYS6sXlrPjyzEi5S2H9exnCQKQc,5658
7
7
  webdev/net.py,sha256=JuEqWyRgy5sKadn3a6BCVFuvjrjL_5ZbUmwhIKCbHLE,5059
8
8
  webdev/run.py,sha256=2fc5sstncBMes7PhVmiEtx5B8RVMSMmF4ISDVTa4OaY,3688
9
9
  webdev/server.py,sha256=O1gWM53MYFhCANlGD9D6N0L2ipm93sczwsxYfiieE3M,10918
10
- webdev/static.py,sha256=rCYsR_l_d0L8_Z0ZSCoWtMayJyYqleqeqjK6-TYiqlE,6613
10
+ webdev/static.py,sha256=jrrykdtX509B5L97JznAPWacerqOYRWx_-D2M8Z0SGc,6808
11
11
  webdev/tls.py,sha256=kUtaKMjssNXnPIzk8pUsEQbbPjQ8UVtdkE2jepusnaA,5861
12
12
  webdev/templates/dark/base.html.jinja2,sha256=GQ3V1ViLMxqLcY6J4pTHBp3z6acAltSscQS1HhLhJn0,441
13
13
  webdev/templates/dark/index.html.jinja2,sha256=Daq_Qq2_eU8tT7MYIT66ifAdCd_atJxdcUKWyR2jdbY,2369
14
14
  webdev/templates/dark/partials/sort.js.jinja2,sha256=UyZGARVjREPhp_ExgwuxvCO5xn8yz-1p0yinAeULcfU,1792
15
15
  webdev/templates/dark/partials/styles.css.jinja2,sha256=LbJsa_ocA0ynzJHkwnwyjdLICFVUgJ27oM6MLpTO_o4,2821
16
- webdev-2.0.0.dist-info/METADATA,sha256=wQWSQp2Mslk-uW4s7SzigbgB5oYEwXbrcgoeOKevCbE,8949
17
- webdev-2.0.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
18
- webdev-2.0.0.dist-info/entry_points.txt,sha256=578xTHeC_DyXogKwIi1QFsIFcRwApzz7odTdApHijvk,43
19
- webdev-2.0.0.dist-info/licenses/LICENSE,sha256=xllut76FgcGL5zbIRvuRc7aezPbvlMUTWJPsVr2Sugg,11358
20
- webdev-2.0.0.dist-info/RECORD,,
16
+ webdev-2.1.0.dist-info/METADATA,sha256=t7sgve1k96jS4JHuuL_n3ApgZvNX0bis6mk1MEGuQ9Y,9934
17
+ webdev-2.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
18
+ webdev-2.1.0.dist-info/entry_points.txt,sha256=578xTHeC_DyXogKwIi1QFsIFcRwApzz7odTdApHijvk,43
19
+ webdev-2.1.0.dist-info/licenses/LICENSE,sha256=xllut76FgcGL5zbIRvuRc7aezPbvlMUTWJPsVr2Sugg,11358
20
+ webdev-2.1.0.dist-info/RECORD,,
File without changes