Skip to content

Instantly share code, notes, and snippets.

@xyx0no646
Last active November 28, 2021 12:46
Show Gist options
  • Save xyx0no646/a51d981c225cfc127a6b2dc3a8893588 to your computer and use it in GitHub Desktop.
Save xyx0no646/a51d981c225cfc127a6b2dc3a8893588 to your computer and use it in GitHub Desktop.
// Deno Ultra Simple Static Server
//
// Copy of this example:
// https://servestjs.org/use-serve-static
/* how to compile
wget https://gist.githubusercontent.com/xyx0no646/a51d981c225cfc127a6b2dc3a8893588/raw/859e4aff4009f87dfaaf19951fb620c4cdb94611/deno_simple_static_server.jsdeno compile --allow-net --allow-read deno_simple_static_server.js
mkdir public
echo helloworld > ./public/index.html
./deno_simple_static_server
then,access localhost:8080
*/
import { createApp, serveStatic } from "https://deno.land/x/servest@v1.3.1/mod.ts";
const app = createApp();
app.use(serveStatic("./public",{ 'index': ['index.html', 'index.htm'] }));
app.listen({ port: 8080 });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment