News for hackers. Stuff that matters.
Re:Show HN: Running a simple local HTTP server in a web page by fregante on Sunday October 31, 2021 @04:04AM (#29055321)
For those who don’t understand what it’s doing (like me at first):

You first have to host these index.html and sw.js on a regular server (or use the URL in the readme) and then this service will serve a folder of your choice directly from your computer.

This is if you ran your trusty Python server from the CLI, except you did it from the browser, with an unchangeable host:port

The folder will appear to be published from the server that hosts that sw.js file.

Re:Show HN: Running a simple local HTTP server in a web page by e12e on Sunday October 31, 2021 @07:46AM (#29056296)
> You first have to host these index.html and sw.js on a regular server

I guess no server worker from a file://-url?

Re:Show HN: Running a simple local HTTP server in a web page by tyingq on Sunday October 31, 2021 @08:28AM (#29056489)
Chrome tells me "Failed to register a ServiceWorker: The URL protocol of the current origin ('null') is not supported." when I try it.
Re:Show HN: Running a simple local HTTP server in a web page by beardyw on Saturday October 30, 2021 @06:28AM (#29047622)
I may be missing the point, but HTTP is a communication protocol. This looks like a file explorer and editor.
Re:Show HN: Running a simple local HTTP server in a web page by stagas on Sunday October 31, 2021 @06:52AM (#29056068)
It is using HTTP, just doing it through browser APIs[0][1] so in this case the server layer is the service worker but it's still happening through HTTP means. So the client and the server are both running in the browser, the only difference is that this "virtual" server can only be accessed by the same browser session. They are very powerful APIs as you can intercept the network layer and do all sorts of hacks, like the OP's project.

[0]: https://developer.mozilla.org/en-US/docs/Web/API/Response

[1]: https://developer.mozilla.org/en-US/docs/Web/API/Service_Wor...

Re:Show HN: Running a simple local HTTP server in a web page by etherdream on Saturday October 30, 2021 @09:03AM (#29048444)
Not the same. Disk files can be browsed via HTTP (HTTPS), so you can preview a local static site directly, without tools such as http-server, SimpleHTTPServer, etc.
Re:Show HN: Running a simple local HTTP server in a web page by cdaringe on Saturday October 30, 2021 @12:47PM (#29050167)
Service worker file loader != HTTP server. You are intercepting requests which are usually fulfilled by HTTP, but you are not implementing or interacting with HTTP.

Even so, cool project.

Re:Show HN: Running a simple local HTTP server in a web page by beardyw on Saturday October 30, 2021 @10:57AM (#29049264)
If the files are served via HTTP I am missing it. A page which is fetched via HTTP and then accesses local files is not an HTTP server.

https://en.m.wikipedia.org/wiki/Hypertext_Transfer_Protocol

Re:Show HN: Running a simple local HTTP server in a web page by stagas on Sunday October 31, 2021 @06:34AM (#29055987)
Genius! I feel the File System Access API[0] has a lot of potential in bringing data ownership back to the users (instead of being held by some server) but it's very under-utilized atm.

Nice work.

[0]: https://developer.mozilla.org/en-US/docs/Web/API/File_System...

Re:Show HN: Running a simple local HTTP server in a web page by la_fayette on Sunday October 31, 2021 @11:42AM (#29057770)
From the title, I thought it would be a web server compiled as web assembly and running in the browser...
Re:Show HN: Running a simple local HTTP server in a web page by etherdream on Sunday October 31, 2021 @11:51AM (#29057845)
You are right. I am planning to add PHP, similar to wasmer-php[0], but based on Service Worker.

[0]: https://github.com/wasmerio/wasmer-php

Re:Show HN: Running a simple local HTTP server in a web page by etherdream on Monday November 01, 2021 @12:44AM (#29063075)
sry, not wasmer-php, but php-in-browser

https://oraoto.github.io/pib/

Re:Show HN: Running a simple local HTTP server in a web page by e-clinton on Saturday October 30, 2021 @09:55AM (#29048768)
This is interesting. It’d be cool to drop in a wysiwyg editor. Could be a fun way to learn basic web dev
Re:Show HN: Running a simple local HTTP server in a web page by AkshitGarg on Sunday October 31, 2021 @11:39AM (#29057742)
You can use vscode's web editor [0] which allows you to open local folders and even run full LSPs for JavaScript, TypeScript and Python

[0]: vscode.dev

Re:Show HN: Running a simple local HTTP server in a web page by tata71 on Sunday October 31, 2021 @01:10AM (#29054653)
Like....Microsoft Frontpage split view?
Re:Show HN: Running a simple local HTTP server in a web page by Tepix on Sunday October 31, 2021 @04:07AM (#29055329)
Where is the source code for the .webm file?
Re:Show HN: Running a simple local HTTP server in a web page by cobertos on Sunday October 31, 2021 @04:20AM (#29055386)
You mean the .mp4 in the README? It seems like it's just a plain link inside the README.md that GitHub previews/displays. Didn't know it did that. The link is:

https://user-images.githubusercontent.com/1072787/138898490-...