Skip to main content
Module

x/fastro/examples/static.ts

Fast and simple web application framework for deno
Go to Latest
File
import { Fastro, Request } from "../mod.ts";
// setup static handler// you must set static: trueconst server = new Fastro({ static: true });server // serve static file with `/` (root) url // `.` (dot) is your current local directory // the server will read all the files in it. // // You can see the contents with the following url: // http://localhost:3000 .static(".") // serve static file with `/static` url // `public` is your local static folder // create if non exist // put all html files and assets in it // // You can see the contents with the following url: // http://localhost:3000/static // // you can access a static file with url: // http://localhost:3000/static/index.html .static("/static", "public") // serve static file with options // if you access the root path of this route // it will search and display index.html // if not found, it will show the content of directory .static("/oke", "public", { index: "index.html" }) .static("/oke/oke/oke/oke/oke", "public") .static("/1234/hi", "public");
// setup url end pointserver.get("/api", (req) => req.send("api"));
await server.listen({ port: 3000 });