Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
recursive-include src/pyouter/webui *
global-exclude __pycache__ *.py[cod] .DS_Store
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Router nodes run their children in parallel. `policy="sequence"` runs them in or

## Local web

Open the current router in a browser. The server binds to `127.0.0.1:8765` and uses only the Python standard library.
Open the current router in a browser. The server binds to `127.0.0.1:8765` and uses only the Python standard library. The page is a [gd5](https://github.com/zigslice/gd5) app: `Layout`, `Tree`, `Button`, `Card`, `Tag`, and the orange theme from that UI kit, served from `pyouter/webui`.

```shell
python test.py --web
Expand Down Expand Up @@ -654,6 +654,10 @@ PYTHONPATH=src python3 -m unittest src.tests.test_cluster -v

## What's new

### 0.13.0

* rewrite the local web ui with the [gd5](https://github.com/zigslice/gd5) engine and orange UI kit

### 0.12.0

* a super-node network requires a shared `--net` secret; a peer without it is not relayed and its streams are refused
Expand Down
6 changes: 6 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ release = register sdist bdist_egg upload
package_dir =
=src
packages = find_namespace:
include_package_data = True

[options.packages.find]
where = src

[options.package_data]
pyouter =
webui/*
webui/**/*

[options.entry_points]
console_scripts = pyouter = pyouter:runner
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
long_description = (this_directory / "README.md").read_text()

setup(name="pyouter",
version="0.12.0",
version="0.13.0",
description="Python command line tasks router",
install_requires=["libp2p>=0.8.0"],
long_description=long_description,
Expand Down
10 changes: 10 additions & 0 deletions src/pyouter/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ def do_GET(self):
if parsed.path == "/":
self._page()
return
if parsed.path.startswith("/webui/"):
from .webui import read_static

asset = read_static(parsed.path)
if asset is None:
self._send(404, {"error": "not found"})
return
body, content_type = asset
self._raw(200, body, content_type)
return
if parsed.path == "/favicon.ico":
self._raw(204, b"", "image/x-icon")
return
Expand Down
10 changes: 10 additions & 0 deletions src/pyouter/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,16 @@ def do_GET(self):
body = self.bridge.page().encode("utf-8")
self._send(200, body, "text/html; charset=utf-8")
return
if parsed.path.startswith("/webui/"):
from pyouter.webui import read_static

asset = read_static(parsed.path)
if asset is None:
self._send(404, b"not found", "text/plain; charset=utf-8")
return
body, content_type = asset
self._send(200, body, content_type)
return
if parsed.path == "/favicon.ico":
self._send(204, b"", "image/x-icon")
return
Expand Down
Loading
Loading