Is it possible to use elixir native http-server to run a index.html on localhost?

Just wondering about is it possible to run a single static page locally (just two files in a project index.html and styles.css) using Elixir-native http-server?

Today, for these purposes I run $ npx http-server in the root folder.
May be there is a same simple method but using Elixir?

I just tried this and it works:

elixir -e ":inets.start; :inets.start(:httpd, port: 8000, server_name: 'local', server_root: './', document_root: './')" --no-halt

First start :inets then use it to start an http server listening on port 8000 and serving the local folder.


Damn, that is extremely neat.

Since there is no elixir specific code there, I bet you can run this with only OTP.

This also might be of interest:

Big list of http static server one-liners

1 Like

As of OTP 27 (currently in rc2) you can do:

erl -S httpd

For a different port:

erl -S httpd serve -p 8081

To serve a different directory:

erl -S httpd serve /some/dir