serve-me-once
Serves some data over HTTP, once. Based on the built-in Python module http.server
.
Installation
pip install git+https://github.com/pbsds/serve-me-once.git#main
Use
from serve_me_once import serve_once, gen_random_port
serve_once(
"Hello, World",
timeout=2,
mime_type="text/html",
port=gen_random_port()
)
or
from serve_me_once import serve_once_in_background, gen_random_port
import time
addr = serve_once_in_background(
"Hello, World",
timeout=2,
mime_type="text/html",
port=gen_random_port()
)
print("Hosting at:", addr)
time.sleep(3)
... Why?
The web version of Netron accepts an URL as a query parameter (example). But serving temporary files is a chore. Hence this.