A light HTTP server on Deno
import App from 'https://dragonfly.fenz.land/App.js';
const app= new App();
app.listenHTTP( '0.0.0.0:8192', );
import App from 'https://dragonfly.fenz.land/App.js';
import Router from 'https://dragonfly.fenz.land/routing/Router.js';
const router= new Router( {
routes: [
{
path: '/',
method: 'GET',
accept: 'text/html',
controller: ()=>'<!DOCTYPE html><h1>Hello World<h1>',
},
],
}, );
const app= new App( { router, }, );
app.listenHTTP( '0.0.0.0:8192', );
/path-to/controller/main.js
export default function index()
{
return 'Home Page';
}
export function hello()
{
return 'Hello!';
}
const router= new Router( {
controllerPath: '/path-to/controller',
routes: [
{
path: '/',
controller: '/main.js',
},
{
path: '/hello',
controller: '/main.js#hello',
},
],
}, );
If you just need a http file server. You can just run:
> deno --allow-net --allow-read https://dragonfly.fenz.land/cli.js
Or you can install the CLI server with:
> deno install dragonfly https://dragonfly.fenz.land/cli.js --allow-net --allow-read
Then you can just run:
Or you can install the CLI server with:
> dragonfly
> dragonfly --host=0.0.0.0:8192
> dragonfly --root=/path-to/your/web-root