ghps 0.6__tar.gz → 0.8__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.
- {ghps-0.6 → ghps-0.8}/CHANGELOG.md +21 -1
- {ghps-0.6 → ghps-0.8}/PKG-INFO +73 -13
- {ghps-0.6 → ghps-0.8}/README.md +48 -9
- {ghps-0.6 → ghps-0.8}/SECURITY.md +2 -2
- {ghps-0.6 → ghps-0.8}/ghps/cli.py +36 -6
- {ghps-0.6 → ghps-0.8}/ghps/params.py +7 -1
- {ghps-0.6 → ghps-0.8}/ghps/server.py +137 -7
- {ghps-0.6 → ghps-0.8}/ghps.egg-info/PKG-INFO +73 -13
- {ghps-0.6 → ghps-0.8}/ghps.egg-info/SOURCES.txt +1 -0
- ghps-0.8/ghps.egg-info/requires.txt +2 -0
- ghps-0.8/pyproject.toml +3 -0
- {ghps-0.6 → ghps-0.8}/requirements-dev.txt +1 -1
- ghps-0.8/requirements-latest.txt +2 -0
- {ghps-0.6 → ghps-0.8}/setup.py +5 -5
- ghps-0.8/tests/test_cli.py +235 -0
- {ghps-0.6 → ghps-0.8}/tests/test_error.py +54 -0
- {ghps-0.6 → ghps-0.8}/tests/test_server.py +128 -0
- ghps-0.6/ghps.egg-info/requires.txt +0 -1
- ghps-0.6/requirements-latest.txt +0 -1
- ghps-0.6/tests/test_cli.py +0 -148
- {ghps-0.6 → ghps-0.8}/AUTHORS.md +0 -0
- {ghps-0.6 → ghps-0.8}/LICENSE +0 -0
- {ghps-0.6 → ghps-0.8}/MANIFEST.in +0 -0
- {ghps-0.6 → ghps-0.8}/ghps/__init__.py +0 -0
- {ghps-0.6 → ghps-0.8}/ghps/__main__.py +0 -0
- {ghps-0.6 → ghps-0.8}/ghps/errors.py +0 -0
- {ghps-0.6 → ghps-0.8}/ghps.egg-info/dependency_links.txt +0 -0
- {ghps-0.6 → ghps-0.8}/ghps.egg-info/entry_points.txt +0 -0
- {ghps-0.6 → ghps-0.8}/ghps.egg-info/top_level.txt +0 -0
- {ghps-0.6 → ghps-0.8}/setup.cfg +0 -0
|
@@ -5,6 +5,24 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
|
+
## [0.8] - 2026-11-08
|
|
9
|
+
### Added
|
|
10
|
+
- `quiet` parameter
|
|
11
|
+
- `--quiet` CLI argument
|
|
12
|
+
- `--config` CLI argument
|
|
13
|
+
- `from_config` method
|
|
14
|
+
### Changed
|
|
15
|
+
- Test system modified
|
|
16
|
+
- Build system modified
|
|
17
|
+
- `Python 3.15` added to `test.yml`
|
|
18
|
+
- `README.md` updated
|
|
19
|
+
## [0.7] - 2026-09-22
|
|
20
|
+
### Added
|
|
21
|
+
- `host` parameter
|
|
22
|
+
- `--host` CLI argument
|
|
23
|
+
### Changed
|
|
24
|
+
- Test system modified
|
|
25
|
+
- `README.md` updated
|
|
8
26
|
## [0.6] - 2026-08-31
|
|
9
27
|
### Added
|
|
10
28
|
- Custom default error page
|
|
@@ -52,7 +70,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
52
70
|
- Command line interface
|
|
53
71
|
- Test system
|
|
54
72
|
|
|
55
|
-
[Unreleased]: https://github.com/sepandhaghighi/ghps/compare/v0.
|
|
73
|
+
[Unreleased]: https://github.com/sepandhaghighi/ghps/compare/v0.8...dev
|
|
74
|
+
[0.8]: https://github.com/sepandhaghighi/ghps/compare/v0.7...v0.8
|
|
75
|
+
[0.7]: https://github.com/sepandhaghighi/ghps/compare/v0.6...v0.7
|
|
56
76
|
[0.6]: https://github.com/sepandhaghighi/ghps/compare/v0.5...v0.6
|
|
57
77
|
[0.5]: https://github.com/sepandhaghighi/ghps/compare/v0.4...v0.5
|
|
58
78
|
[0.4]: https://github.com/sepandhaghighi/ghps/compare/v0.3...v0.4
|
{ghps-0.6 → ghps-0.8}/PKG-INFO
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ghps
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8
|
|
4
4
|
Summary: Ghps: A Minimal GitHub Pages Simulator for Local Development
|
|
5
5
|
Home-page: https://github.com/sepandhaghighi/ghps
|
|
6
|
-
Download-URL: https://github.com/sepandhaghighi/ghps/tarball/v0.
|
|
6
|
+
Download-URL: https://github.com/sepandhaghighi/ghps/tarball/v0.8
|
|
7
7
|
Author: Sepand Haghighi
|
|
8
8
|
Author-email: me@sepand.tech
|
|
9
9
|
License: MIT
|
|
@@ -11,7 +11,6 @@ Project-URL: Source, https://github.com/sepandhaghighi/ghps
|
|
|
11
11
|
Keywords: github gh-pages static-server static-hosting development server local http simulator testing cli python
|
|
12
12
|
Classifier: Development Status :: 4 - Beta
|
|
13
13
|
Classifier: Natural Language :: English
|
|
14
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
15
14
|
Classifier: Operating System :: OS Independent
|
|
16
15
|
Classifier: Environment :: Console
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.7
|
|
@@ -22,6 +21,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
22
21
|
Classifier: Programming Language :: Python :: 3.12
|
|
23
22
|
Classifier: Programming Language :: Python :: 3.13
|
|
24
23
|
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
25
25
|
Classifier: Intended Audience :: Developers
|
|
26
26
|
Classifier: Intended Audience :: Education
|
|
27
27
|
Classifier: Topic :: Utilities
|
|
@@ -33,6 +33,7 @@ Description-Content-Type: text/markdown
|
|
|
33
33
|
License-File: LICENSE
|
|
34
34
|
License-File: AUTHORS.md
|
|
35
35
|
Requires-Dist: art>=5.3
|
|
36
|
+
Requires-Dist: tomli>=2.0.2
|
|
36
37
|
Dynamic: author
|
|
37
38
|
Dynamic: author-email
|
|
38
39
|
Dynamic: classifier
|
|
@@ -62,7 +63,7 @@ Dynamic: summary
|
|
|
62
63
|
## Overview
|
|
63
64
|
|
|
64
65
|
<p align="justify">
|
|
65
|
-
<b>Ghps</b> is a minimal
|
|
66
|
+
<b>Ghps</b> is a minimal GitHub Pages simulator written in pure Python for local development and testing. It accurately replicates GitHub Pages' static hosting behavior, including proper <code>404.html</code> handling, project base path simulation, strict routing mode, and optional cache control - all while remaining lightweight, fast, and usable both as a CLI tool and as an importable Python library.
|
|
66
67
|
</p>
|
|
67
68
|
|
|
68
69
|
<table>
|
|
@@ -101,13 +102,13 @@ Dynamic: summary
|
|
|
101
102
|
## Installation
|
|
102
103
|
|
|
103
104
|
### Source Code
|
|
104
|
-
- Download [Version 0.
|
|
105
|
+
- Download [Version 0.8](https://github.com/sepandhaghighi/ghps/archive/v0.8.zip) or [Latest Source](https://github.com/sepandhaghighi/ghps/archive/dev.zip)
|
|
105
106
|
- `pip install .`
|
|
106
107
|
|
|
107
108
|
### PyPI
|
|
108
109
|
|
|
109
110
|
- Check [Python Packaging User Guide](https://packaging.python.org/installing/)
|
|
110
|
-
- `pip install ghps==0.
|
|
111
|
+
- `pip install ghps==0.8`
|
|
111
112
|
|
|
112
113
|
|
|
113
114
|
## Usage
|
|
@@ -117,13 +118,15 @@ Ghps can be used both as a CLI tool and as a Python library.
|
|
|
117
118
|
### CLI
|
|
118
119
|
|
|
119
120
|
```bash
|
|
120
|
-
ghps --port=8080 --no-cache --no-threaded
|
|
121
|
+
ghps --host=127.0.0.1 --port=8080 --no-cache --no-threaded
|
|
121
122
|
```
|
|
122
123
|
|
|
123
124
|
#### Options
|
|
124
125
|
|
|
125
126
|
| Option | Description | Default |
|
|
126
127
|
|--------|-------------|----------|
|
|
128
|
+
| `-c, --config` | Path to configuration file | Auto discovers `.ghps` |
|
|
129
|
+
| `--host` | Host address to bind to | `localhost` |
|
|
127
130
|
| `-p, --port` | Port to serve on | `8000` |
|
|
128
131
|
| `-d, --directory` | Directory to serve | Current directory (`.`) |
|
|
129
132
|
| `-b, --base-path` | Base path for project pages (e.g. `/repo-name`) | `""` |
|
|
@@ -132,8 +135,16 @@ ghps --port=8080 --no-cache --no-threaded
|
|
|
132
135
|
| `--no-threaded` | Disable threaded server | Threaded enabled |
|
|
133
136
|
| `--auto-open` | Automatically open the server URL | Disable |
|
|
134
137
|
| `--directory-listing` | Enable directory listing | Disable |
|
|
138
|
+
| `--quiet` | Suppress informational server output | Disable |
|
|
135
139
|
|
|
136
|
-
|
|
140
|
+
> [!NOTE]
|
|
141
|
+
> You can set `--port=0` to let the OS automatically select an available port.
|
|
142
|
+
|
|
143
|
+
> [!NOTE]
|
|
144
|
+
> You can use `--host=0.0.0.0` to bind Ghps to all available network interfaces, or specify a particular address such as `127.0.0.1`.
|
|
145
|
+
|
|
146
|
+
> [!NOTE]
|
|
147
|
+
> Ghps automatically looks for a `.ghps` configuration file in the served directory if available, or you can specify a custom configuration file path using `-c` / `--config`.
|
|
137
148
|
|
|
138
149
|
|
|
139
150
|
### Library
|
|
@@ -141,17 +152,23 @@ ghps --port=8080 --no-cache --no-threaded
|
|
|
141
152
|
```python
|
|
142
153
|
from ghps import GHPageServer
|
|
143
154
|
|
|
144
|
-
|
|
155
|
+
server1 = GHPageServer(
|
|
145
156
|
directory="dist",
|
|
157
|
+
host="localhost",
|
|
146
158
|
port=5000,
|
|
147
159
|
base_path="/repo-name",
|
|
148
160
|
strict=True,
|
|
149
161
|
no_cache=False,
|
|
150
162
|
threaded=True,
|
|
151
|
-
|
|
163
|
+
auto_open=True,
|
|
164
|
+
quiet=False,
|
|
152
165
|
)
|
|
153
166
|
|
|
154
|
-
|
|
167
|
+
server1.start()
|
|
168
|
+
|
|
169
|
+
server2 = GHPageServer.from_config(config="config.toml")
|
|
170
|
+
|
|
171
|
+
server2.start()
|
|
155
172
|
```
|
|
156
173
|
|
|
157
174
|
#### Parameters
|
|
@@ -159,6 +176,7 @@ server.start()
|
|
|
159
176
|
| Parameter | Type | Description | Default |
|
|
160
177
|
|------------|------|-------------|----------|
|
|
161
178
|
| `directory` | `str` | Directory to serve | `"."` |
|
|
179
|
+
| `host` | `str` | Host address to bind the server to | `"localhost"` |
|
|
162
180
|
| `port` | `int` | Port number | `8000` |
|
|
163
181
|
| `base_path` | `str` | Base path for project page simulation | `""` |
|
|
164
182
|
| `strict` | `bool` | Enforce GitHub-like routing behavior | `True` |
|
|
@@ -166,8 +184,30 @@ server.start()
|
|
|
166
184
|
| `threaded` | `bool` | Enable threaded request handling | `True` |
|
|
167
185
|
| `auto_open` | `bool` | Automatically open the server URL | `False` |
|
|
168
186
|
| `directory_listing` | `bool` | Enable directory listing | `False` |
|
|
187
|
+
| `quiet` | `bool` | Suppress informational server output | `False` |
|
|
188
|
+
|
|
189
|
+
> [!NOTE]
|
|
190
|
+
> You can set `port=0` to let the OS automatically select an available port.
|
|
169
191
|
|
|
170
|
-
|
|
192
|
+
> [!NOTE]
|
|
193
|
+
> The `host` parameter controls the network interface used for server binding. The default is `"localhost"`.
|
|
194
|
+
|
|
195
|
+
### Configuration File
|
|
196
|
+
|
|
197
|
+
You can define your server settings in a **TOML** configuration file (typically named `.ghps`):
|
|
198
|
+
|
|
199
|
+
```toml
|
|
200
|
+
directory = "dist"
|
|
201
|
+
host = "localhost"
|
|
202
|
+
port = 8080
|
|
203
|
+
base_path = "/repo-name"
|
|
204
|
+
strict = true
|
|
205
|
+
no_cache = false
|
|
206
|
+
threaded = true
|
|
207
|
+
auto_open = false
|
|
208
|
+
directory_listing = false
|
|
209
|
+
quiet = false
|
|
210
|
+
```
|
|
171
211
|
|
|
172
212
|
## Issues & Bug Reports
|
|
173
213
|
|
|
@@ -218,6 +258,24 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
|
218
258
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
219
259
|
|
|
220
260
|
## [Unreleased]
|
|
261
|
+
## [0.8] - 2026-11-08
|
|
262
|
+
### Added
|
|
263
|
+
- `quiet` parameter
|
|
264
|
+
- `--quiet` CLI argument
|
|
265
|
+
- `--config` CLI argument
|
|
266
|
+
- `from_config` method
|
|
267
|
+
### Changed
|
|
268
|
+
- Test system modified
|
|
269
|
+
- Build system modified
|
|
270
|
+
- `Python 3.15` added to `test.yml`
|
|
271
|
+
- `README.md` updated
|
|
272
|
+
## [0.7] - 2026-09-22
|
|
273
|
+
### Added
|
|
274
|
+
- `host` parameter
|
|
275
|
+
- `--host` CLI argument
|
|
276
|
+
### Changed
|
|
277
|
+
- Test system modified
|
|
278
|
+
- `README.md` updated
|
|
221
279
|
## [0.6] - 2026-08-31
|
|
222
280
|
### Added
|
|
223
281
|
- Custom default error page
|
|
@@ -265,7 +323,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
265
323
|
- Command line interface
|
|
266
324
|
- Test system
|
|
267
325
|
|
|
268
|
-
[Unreleased]: https://github.com/sepandhaghighi/ghps/compare/v0.
|
|
326
|
+
[Unreleased]: https://github.com/sepandhaghighi/ghps/compare/v0.8...dev
|
|
327
|
+
[0.8]: https://github.com/sepandhaghighi/ghps/compare/v0.7...v0.8
|
|
328
|
+
[0.7]: https://github.com/sepandhaghighi/ghps/compare/v0.6...v0.7
|
|
269
329
|
[0.6]: https://github.com/sepandhaghighi/ghps/compare/v0.5...v0.6
|
|
270
330
|
[0.5]: https://github.com/sepandhaghighi/ghps/compare/v0.4...v0.5
|
|
271
331
|
[0.4]: https://github.com/sepandhaghighi/ghps/compare/v0.3...v0.4
|
{ghps-0.6 → ghps-0.8}/README.md
RENAMED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
## Overview
|
|
12
12
|
|
|
13
13
|
<p align="justify">
|
|
14
|
-
<b>Ghps</b> is a minimal
|
|
14
|
+
<b>Ghps</b> is a minimal GitHub Pages simulator written in pure Python for local development and testing. It accurately replicates GitHub Pages' static hosting behavior, including proper <code>404.html</code> handling, project base path simulation, strict routing mode, and optional cache control - all while remaining lightweight, fast, and usable both as a CLI tool and as an importable Python library.
|
|
15
15
|
</p>
|
|
16
16
|
|
|
17
17
|
<table>
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
## Installation
|
|
51
51
|
|
|
52
52
|
### Source Code
|
|
53
|
-
- Download [Version 0.
|
|
53
|
+
- Download [Version 0.8](https://github.com/sepandhaghighi/ghps/archive/v0.8.zip) or [Latest Source](https://github.com/sepandhaghighi/ghps/archive/dev.zip)
|
|
54
54
|
- `pip install .`
|
|
55
55
|
|
|
56
56
|
### PyPI
|
|
57
57
|
|
|
58
58
|
- Check [Python Packaging User Guide](https://packaging.python.org/installing/)
|
|
59
|
-
- `pip install ghps==0.
|
|
59
|
+
- `pip install ghps==0.8`
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
## Usage
|
|
@@ -66,13 +66,15 @@ Ghps can be used both as a CLI tool and as a Python library.
|
|
|
66
66
|
### CLI
|
|
67
67
|
|
|
68
68
|
```bash
|
|
69
|
-
ghps --port=8080 --no-cache --no-threaded
|
|
69
|
+
ghps --host=127.0.0.1 --port=8080 --no-cache --no-threaded
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
#### Options
|
|
73
73
|
|
|
74
74
|
| Option | Description | Default |
|
|
75
75
|
|--------|-------------|----------|
|
|
76
|
+
| `-c, --config` | Path to configuration file | Auto discovers `.ghps` |
|
|
77
|
+
| `--host` | Host address to bind to | `localhost` |
|
|
76
78
|
| `-p, --port` | Port to serve on | `8000` |
|
|
77
79
|
| `-d, --directory` | Directory to serve | Current directory (`.`) |
|
|
78
80
|
| `-b, --base-path` | Base path for project pages (e.g. `/repo-name`) | `""` |
|
|
@@ -81,8 +83,16 @@ ghps --port=8080 --no-cache --no-threaded
|
|
|
81
83
|
| `--no-threaded` | Disable threaded server | Threaded enabled |
|
|
82
84
|
| `--auto-open` | Automatically open the server URL | Disable |
|
|
83
85
|
| `--directory-listing` | Enable directory listing | Disable |
|
|
86
|
+
| `--quiet` | Suppress informational server output | Disable |
|
|
84
87
|
|
|
85
|
-
|
|
88
|
+
> [!NOTE]
|
|
89
|
+
> You can set `--port=0` to let the OS automatically select an available port.
|
|
90
|
+
|
|
91
|
+
> [!NOTE]
|
|
92
|
+
> You can use `--host=0.0.0.0` to bind Ghps to all available network interfaces, or specify a particular address such as `127.0.0.1`.
|
|
93
|
+
|
|
94
|
+
> [!NOTE]
|
|
95
|
+
> Ghps automatically looks for a `.ghps` configuration file in the served directory if available, or you can specify a custom configuration file path using `-c` / `--config`.
|
|
86
96
|
|
|
87
97
|
|
|
88
98
|
### Library
|
|
@@ -90,17 +100,23 @@ ghps --port=8080 --no-cache --no-threaded
|
|
|
90
100
|
```python
|
|
91
101
|
from ghps import GHPageServer
|
|
92
102
|
|
|
93
|
-
|
|
103
|
+
server1 = GHPageServer(
|
|
94
104
|
directory="dist",
|
|
105
|
+
host="localhost",
|
|
95
106
|
port=5000,
|
|
96
107
|
base_path="/repo-name",
|
|
97
108
|
strict=True,
|
|
98
109
|
no_cache=False,
|
|
99
110
|
threaded=True,
|
|
100
|
-
|
|
111
|
+
auto_open=True,
|
|
112
|
+
quiet=False,
|
|
101
113
|
)
|
|
102
114
|
|
|
103
|
-
|
|
115
|
+
server1.start()
|
|
116
|
+
|
|
117
|
+
server2 = GHPageServer.from_config(config="config.toml")
|
|
118
|
+
|
|
119
|
+
server2.start()
|
|
104
120
|
```
|
|
105
121
|
|
|
106
122
|
#### Parameters
|
|
@@ -108,6 +124,7 @@ server.start()
|
|
|
108
124
|
| Parameter | Type | Description | Default |
|
|
109
125
|
|------------|------|-------------|----------|
|
|
110
126
|
| `directory` | `str` | Directory to serve | `"."` |
|
|
127
|
+
| `host` | `str` | Host address to bind the server to | `"localhost"` |
|
|
111
128
|
| `port` | `int` | Port number | `8000` |
|
|
112
129
|
| `base_path` | `str` | Base path for project page simulation | `""` |
|
|
113
130
|
| `strict` | `bool` | Enforce GitHub-like routing behavior | `True` |
|
|
@@ -115,8 +132,30 @@ server.start()
|
|
|
115
132
|
| `threaded` | `bool` | Enable threaded request handling | `True` |
|
|
116
133
|
| `auto_open` | `bool` | Automatically open the server URL | `False` |
|
|
117
134
|
| `directory_listing` | `bool` | Enable directory listing | `False` |
|
|
135
|
+
| `quiet` | `bool` | Suppress informational server output | `False` |
|
|
136
|
+
|
|
137
|
+
> [!NOTE]
|
|
138
|
+
> You can set `port=0` to let the OS automatically select an available port.
|
|
118
139
|
|
|
119
|
-
|
|
140
|
+
> [!NOTE]
|
|
141
|
+
> The `host` parameter controls the network interface used for server binding. The default is `"localhost"`.
|
|
142
|
+
|
|
143
|
+
### Configuration File
|
|
144
|
+
|
|
145
|
+
You can define your server settings in a **TOML** configuration file (typically named `.ghps`):
|
|
146
|
+
|
|
147
|
+
```toml
|
|
148
|
+
directory = "dist"
|
|
149
|
+
host = "localhost"
|
|
150
|
+
port = 8080
|
|
151
|
+
base_path = "/repo-name"
|
|
152
|
+
strict = true
|
|
153
|
+
no_cache = false
|
|
154
|
+
threaded = true
|
|
155
|
+
auto_open = false
|
|
156
|
+
directory_listing = false
|
|
157
|
+
quiet = false
|
|
158
|
+
```
|
|
120
159
|
|
|
121
160
|
## Issues & Bug Reports
|
|
122
161
|
|
|
@@ -32,55 +32,81 @@ def _parse_args() -> argparse.Namespace:
|
|
|
32
32
|
help="Version"
|
|
33
33
|
)
|
|
34
34
|
|
|
35
|
+
parser.add_argument(
|
|
36
|
+
"-c", "--config",
|
|
37
|
+
type=str,
|
|
38
|
+
default=None,
|
|
39
|
+
help="Path to configuration file"
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
parser.add_argument(
|
|
43
|
+
"--host",
|
|
44
|
+
type=str,
|
|
45
|
+
default=None,
|
|
46
|
+
help="Host address to bind to (default: localhost)"
|
|
47
|
+
)
|
|
48
|
+
|
|
35
49
|
parser.add_argument(
|
|
36
50
|
"-p", "--port",
|
|
37
51
|
type=int,
|
|
38
|
-
default=
|
|
52
|
+
default=None,
|
|
39
53
|
help="Port to serve on (default: 8000, use 0 for automatic allocation)"
|
|
40
54
|
)
|
|
41
55
|
|
|
42
56
|
parser.add_argument(
|
|
43
57
|
"-d", "--directory",
|
|
44
|
-
default=
|
|
58
|
+
default=None,
|
|
45
59
|
help="Directory to serve (default: current directory)"
|
|
46
60
|
)
|
|
47
61
|
|
|
48
62
|
parser.add_argument(
|
|
49
63
|
"-b", "--base-path",
|
|
50
|
-
default=
|
|
64
|
+
default=None,
|
|
51
65
|
help="Base path for project pages (e.g. /repo-name)"
|
|
52
66
|
)
|
|
53
67
|
|
|
54
68
|
parser.add_argument(
|
|
55
69
|
"--no-strict",
|
|
56
70
|
action="store_true",
|
|
71
|
+
default=None,
|
|
57
72
|
help="Enable .html fallback"
|
|
58
73
|
)
|
|
59
74
|
|
|
60
75
|
parser.add_argument(
|
|
61
76
|
"--no-cache",
|
|
62
77
|
action="store_true",
|
|
78
|
+
default=None,
|
|
63
79
|
help="Disable HTTP caching headers"
|
|
64
80
|
)
|
|
65
81
|
|
|
66
82
|
parser.add_argument(
|
|
67
83
|
"--no-threaded",
|
|
68
84
|
action="store_true",
|
|
85
|
+
default=None,
|
|
69
86
|
help="Disable threaded server"
|
|
70
87
|
)
|
|
71
88
|
|
|
72
89
|
parser.add_argument(
|
|
73
90
|
"--auto-open",
|
|
74
91
|
action="store_true",
|
|
92
|
+
default=None,
|
|
75
93
|
help="Automatically open the server URL"
|
|
76
94
|
)
|
|
77
95
|
|
|
78
96
|
parser.add_argument(
|
|
79
97
|
"--directory-listing",
|
|
80
98
|
action="store_true",
|
|
99
|
+
default=None,
|
|
81
100
|
help="Enable directory listing"
|
|
82
101
|
)
|
|
83
102
|
|
|
103
|
+
parser.add_argument(
|
|
104
|
+
"--quiet",
|
|
105
|
+
action="store_true",
|
|
106
|
+
default=None,
|
|
107
|
+
help="Suppress informational server output"
|
|
108
|
+
)
|
|
109
|
+
|
|
84
110
|
args = parser.parse_args()
|
|
85
111
|
return args
|
|
86
112
|
|
|
@@ -92,15 +118,19 @@ def main() -> None:
|
|
|
92
118
|
if args.version:
|
|
93
119
|
print(GHPS_VERSION)
|
|
94
120
|
else:
|
|
95
|
-
server = GHPageServer(
|
|
121
|
+
server = GHPageServer.from_config(
|
|
96
122
|
directory=args.directory,
|
|
123
|
+
host=args.host,
|
|
97
124
|
port=args.port,
|
|
98
125
|
base_path=args.base_path,
|
|
99
|
-
strict=
|
|
126
|
+
strict=False if args.no_strict else None,
|
|
100
127
|
no_cache=args.no_cache,
|
|
101
|
-
threaded=
|
|
128
|
+
threaded=False if args.no_threaded else None,
|
|
102
129
|
auto_open=args.auto_open,
|
|
103
130
|
directory_listing=args.directory_listing,
|
|
131
|
+
quiet=args.quiet,
|
|
132
|
+
config=args.config,
|
|
133
|
+
auto_discover=True,
|
|
104
134
|
)
|
|
105
135
|
server.start()
|
|
106
136
|
except GHPSError as e:
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
"""ghps params."""
|
|
3
3
|
|
|
4
|
-
GHPS_VERSION = "0.
|
|
4
|
+
GHPS_VERSION = "0.8"
|
|
5
5
|
GHPS_REPO = "https://github.com/sepandhaghighi/ghps"
|
|
6
6
|
|
|
7
7
|
INVALID_DIRECTORY_TYPE_ERROR = "`directory` must be str or pathlib.Path."
|
|
8
8
|
DIRECTORY_NOT_FOUND_ERROR = "`directory` does not exist."
|
|
9
9
|
DIRECTORY_NOT_DIR_ERROR = "`directory` must be a valid directory."
|
|
10
10
|
|
|
11
|
+
INVALID_HOST_TYPE_ERROR = "`host` must be str."
|
|
11
12
|
INVALID_PORT_TYPE_ERROR = "`port` must be int."
|
|
12
13
|
INVALID_PORT_RANGE_ERROR = "`port` must be between 0 and 65535."
|
|
13
14
|
|
|
@@ -19,6 +20,11 @@ INVALID_NO_CACHE_TYPE_ERROR = "`no_cache` must be bool."
|
|
|
19
20
|
INVALID_THREADED_TYPE_ERROR = "`threaded` must be bool."
|
|
20
21
|
INVALID_AUTO_OPEN_TYPE_ERROR = "`auto_open` must be bool."
|
|
21
22
|
INVALID_DIRECTORY_LISTING_TYPE_ERROR = "`directory_listing` must be bool."
|
|
23
|
+
INVALID_QUIET_TYPE_ERROR = "`quiet` must be bool."
|
|
24
|
+
|
|
25
|
+
INVALID_CONFIG_TYPE_ERROR = "`config` must be str, pathlib.Path, or dict."
|
|
26
|
+
INVALID_CONFIG_FILE_ERROR = "Failed to load config file: {error}"
|
|
27
|
+
INVALID_CONFIG_FORMAT_ERROR = "Config file content must be a valid TOML format."
|
|
22
28
|
|
|
23
29
|
PORT_IN_USE_ERROR = "`port` is already in use. Try another port or use `0` for automatic allocation."
|
|
24
30
|
PORT_ACCESS_DENIED_ERROR = "`port` access denied. Try a different port or check permissions."
|