Simple static web server


#1

I have a work-in-progress GUI library that uses the platform’s webview in a window, but unfortunately I can’t send any Web Assembly or media to it without a static file server, opened at 127.0.0.1:0. Is there a simple, easy-to-use, small (compiled size) library that I can use for this purpose?

Also, I’m trying to make this library as easy-to-use as possible, so would it be better to just point people to this server, or wrap the server in the library itself, maybe as a trait method fn resource(&self, path: &str) -> Response { code: u16, mime: &str, data: &[u8] }?

Edit: Fixed the IP address thanks to @SergejJurecko.


#2

Also do not open server at 0.0.0.0:0 as this means it can be called from the network. It is a security issue and it will cause a popup on windows asking the user to confirm opening a port. Open it at 127.0.0.1:0.


#3

Keep in mind WebAssembly is not supported on IE11 which is what is used if you use webview on windows.


#4

Yeah, I know - I made my own wrapper with UWP (along with some feature additions on macOS and Linux), and hopefully it’ll be merged back into zserge/webview some time in the future.


#5