Skip to content
German Escobar edited this page Feb 4, 2014 · 2 revisions

This guide will show you how to serve static files using the StaticMiddleware.

The easiest way of configuring the StaticMiddleware is to pass a path (relative or absolute) to the constructor. For example:

  StaticMiddleware statik  = new StaticMiddleware("assets");
  
  Jogger jogger = new Jogger(statik);
  jogger.listen();

Every time a request is received with the /assets prefix (e.g. http://localhost:5000/assets/style.css), the middleware will handle the request and will search for the requested file inside the assets folder (relative to where the project is running).

You can also specify the prefix in which you want to serve the static files. For example:

  StaticMiddleware statik = new StaticMiddleware("/var/www/static", "assets");

  Jogger jogger = new Jogger(statik);
  jogger.listen();

In this case, every time a request is received with the /assets prefix, the middleware will search for the requested file in the /var/www/static folder.

Clone this wiki locally