summaryrefslogtreecommitdiff
path: root/file_server.ts
diff options
context:
space:
mode:
Diffstat (limited to 'file_server.ts')
-rw-r--r--file_server.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/file_server.ts b/file_server.ts
new file mode 100644
index 000000000..9d3d5366e
--- /dev/null
+++ b/file_server.ts
@@ -0,0 +1,18 @@
+import { listenAndServe } from "./http.ts";
+import { open, cwd } from "deno";
+
+const addr = "0.0.0.0:4500";
+const d = cwd();
+
+listenAndServe(addr, async (req) => {
+ const filename = d + "/" + req.url;
+ let res;
+ try {
+ res = { status: 200, body: open(filename) };
+ } catch(e) {
+ res = { status: 500, body: "bad" };
+ }
+ req.respond(res);
+});
+
+console.log(`HTTP server listening on http://${addr}/`);