darkhttpd icon indicating copy to clipboard operation
darkhttpd copied to clipboard

Add an option to serve a single file for all requests

Open iliazeus opened this issue 2 years ago • 5 comments

Often, I want to just share a single file over HTTP. Right now, we can only pass a directory to darkhttpd, and it will serve any file from that directory. I would love to be able to do darkhttpd ./my/single/file.html.

iliazeus avatar Mar 24 '22 14:03 iliazeus

Why not create a directory with the single file you want to serve?

kugland avatar Dec 10 '22 07:12 kugland

@kugland the same reason I don't just spin up nginx instead: it's way less convenient.

iliazeus avatar Dec 11 '22 04:12 iliazeus

I have this use case as well. I just need to serve a single HTML page on localhost, which I request using window.open() on Chromium, then I register a ServiceWorker from a script in the HTML which is used to stream data to the Tab which opened the window. I don't even need darkhttpd to remain active once the single request is served. I can use Native Messaging to start the local server, ideally the server would terminate itself once the request is served - the script and ServiceWorker in the served HTML will remain active.

guest271314 avatar Mar 19 '23 19:03 guest271314

I can kinda appreciate this from a simplicity and security standpoint - locking serving down to a single path. Who wants to implement it?

emikulic avatar Mar 20 '23 02:03 emikulic

I am not an expert in C. Otherwise I would file a PR as this is exactly what I am looking for for my own projects in the browser and potentially as a base to import into QuickJS.

guest271314 avatar Mar 20 '23 05:03 guest271314