microscope v0.3.0 Microscope

Microscope is a simple static web server built using cowboy. It’s purpose is to provide an easy way to test your static websites.

Getting started

Use Microscope.start_link/3 to start the web server.

# Example:
iex> {:ok, pid} = Microscope.start_link("/home/user/www", "/base", 8080)

Then the HTTP server will start listening on port 8080, and when the user requests /base/path/to/file, the server will respond with the contents of /home/user/www/path/to/file on your system.

Microscope can also handle directory requests. In this case, the web server will look for index.html or index.htm under the specified directory and serve the file if found.

Summary

Functions

Starts Microscope simple static web server

Functions

start_link(src, base, port, cb_mods \\ [])
start_link(String.t, String.t, pos_integer, [module]) :: {:ok, pid}

Starts Microscope simple static web server.

The server will start listening on port specified by port argument. The server expects request URLs starting with base, so when a user requests <base>/file, the server will respond with the contents of <src>/file on disk, any other request URLs will result in 404.

cb_mods argument expects a list of modules, each module implementing Microscope.Callback behaviour. For example, if you want a line of access log printed on every requests, use the built-in Microscope.Logger module.