Single-command startup and fix bookmarklet
app.py now auto-starts the gateway HTTP server in a daemon thread, so users only need `python app.py` to get everything running. The gateway calls dispatch_request directly when co-located (local mode) instead of trying to establish an RNS link to itself. Bookmarklet hardcoded to localhost:8080. gateway.py still works standalone for connecting to remote instances. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9a9b5e0617
commit
4e4cc69e0f
3 changed files with 52 additions and 34 deletions
|
|
@ -308,12 +308,11 @@ def handle_import_submit(body):
|
|||
return handle_import_form(f"Imported {imported} page(s). {errors} error(s).")
|
||||
|
||||
|
||||
def handle_style_form(msg="", gateway_host=""):
|
||||
def handle_style_form(msg=""):
|
||||
css = get_setting("custom_css")
|
||||
name = get_site_name()
|
||||
sharing = get_setting("sharing_enabled", "0")
|
||||
checked = " checked" if sharing == "1" else ""
|
||||
host = gateway_host or "localhost:8080"
|
||||
return _respond(
|
||||
f"<h1>customize</h1>"
|
||||
f"<h2>name your search engine</h2>"
|
||||
|
|
@ -340,7 +339,7 @@ def handle_style_form(msg="", gateway_host=""):
|
|||
f"</form>"
|
||||
f"<h2>bookmarklet</h2>"
|
||||
f"<p>Drag this link to your bookmarks bar. Click it on any page to index it instantly.</p>"
|
||||
f'<p><a href="javascript:void(fetch(\'http://{esc(host)}/bookmark?url=\'+encodeURIComponent(location.href)).then(r=>r.text()).then(t=>alert(t)).catch(()=>alert(\'tinyweb not running\')))">+ save to {esc(name)}</a></p>'
|
||||
f'<p><a href="javascript:void(fetch(\'http://localhost:8080/bookmark?url=\'+encodeURIComponent(location.href)).then(r=>r.text()).then(t=>alert(t)).catch(()=>alert(\'tinyweb not running\')))">+ save to {esc(name)}</a></p>'
|
||||
f"<p>{msg}</p>"
|
||||
f'<a href="/">back</a>'
|
||||
)
|
||||
|
|
@ -651,7 +650,7 @@ def dispatch_request(data):
|
|||
elif path == "/bookmark":
|
||||
return handle_bookmark(query)
|
||||
elif path == "/style":
|
||||
return handle_style_form(gateway_host=gateway_host)
|
||||
return handle_style_form()
|
||||
elif path == "/export":
|
||||
return handle_export()
|
||||
elif path == "/import":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue