NOTICE: 2021/04/09 no longer hosts typescript files. Use

Host static files

serveStatic is a built-in middleware for hosting static files (html, image, stylesheets and more).

In the example below, all files in ./public directories are automatically served if request path matches file. For instance, ./public/index.csswill be served as

If no files found on requested path, request will be passed into the next middleware.

import { createApp, serveStatic } from "[email protected]/mod.ts";
const app = createApp();
// All requests will be processed and matched files in "public" directory
// are served automatically
// Otherwise, request will be passed to next handler
app.listen({ port: 8899 });