bound to 0.0.0.0, dynamic Host header
Makes the server accessible from other devices on the network instead of only localhost. The bookmarklet now uses the Host header from the request so it works regardless of how the server is accessed.
This commit is contained in:
parent
1b27890c46
commit
7caafd665c
2 changed files with 3 additions and 3 deletions
6
app.py
6
app.py
|
|
@ -505,7 +505,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||||
f"</form>"
|
f"</form>"
|
||||||
f"<h2>bookmarklet</h2>"
|
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>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://localhost:5001/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://{esc(self.headers.get("Host", "localhost:5001"))}/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"<p>{msg}</p>"
|
||||||
f'<a href="/">back</a>'
|
f'<a href="/">back</a>'
|
||||||
)
|
)
|
||||||
|
|
@ -520,5 +520,5 @@ class Handler(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
init_db()
|
init_db()
|
||||||
print("running on http://localhost:5001")
|
print("running on http://0.0.0.0:5001")
|
||||||
HTTPServer(("localhost", 5001), Handler).serve_forever()
|
HTTPServer(("0.0.0.0", 5001), Handler).serve_forever()
|
||||||
|
|
|
||||||
BIN
index.db
BIN
index.db
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue