fs editor on runkit

node v14.20.1
version: 1.0.0
endpointsharetweet
const express = require("express"), {readFileSync, readdirSync, writeFileSync, removeSync, statSync, existsSync, mkdirSync} = require("fs"); express().get("*", function(req, res) { if(existsSync("." + req.path)) { if(statSync("." + req.path).isFile()) { res.type(req.path.split("/").slice(-1)[0].split(".").slice(-1)[0]).send(readFileSync("." + req.path)); } else { res.status(300).type("txt").send(readdirSync("." + req.path).join("\n")); } } else { res.status(404).type("txt").send("Not found"); } }).listen(8888); undefined;
Loading…

no comments

    sign in to comment