Microscope is a simple static web server written in Elixir using cowboy.
Originally it was a part of Serum development server, but I decided to separate into the other project for better maintainability. Now it became a general purpose static web server suitable for testing your static websites or quickly sharing your files over HTTP.
Add microscope
to your list of dependencies in mix.exs
:
def deps do
[{:microscope, "~> 1.0"}]
end
Start Microscope using Microscope.start_link/3
.
{:ok, pid} =
Microscope.start_link("/home/user/www", [base: "/base/url", port: 8080])
The server will start listening on port 8080
. Open a web browser and navigate
to http://<your-host>:8080/base/url/path/to/file
, and the contents of
/home/user/www/path/to/file
will be displayed.
You may request either a file or a directory. If you request a file, Microscope
will try to serve the requested file, or respond with HTTP 404 if the file does
not exist. And if you request a directory, Microscope will look for index.html
or index.htm
inside the requested directory and serve one if found.
Microscope also comes with a Mix task which provides a way to launch a static web server right away.
For example, suppose you have generated docs for your project with ExDoc, and you want to see them before publishing to Hex. Then, simply type the command below:
% mix microscope doc
Now open a web browser and navigate to http://<your-host>:8080/
to see the
docs. Easy and real quick! 🚀
Type mix microscope
on your shell to see all possible startup options.
MIT. Please read LICENSE
file for the full text.