forked from hnasr/javascript_playground
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
25 lines (22 loc) · 608 Bytes
/
index.js
File metadata and controls
25 lines (22 loc) · 608 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import {serve, serveTLS} from "https://deno.land/[email protected]/http/server.ts"
/*
const server = serveTLS({
"hostname": "127.0.0.1",
"port": 8080,
"certFile" :"cert.pem",
"keyFile": "private.pem"
})*/
const server = serve({
"hostname": "127.0.0.1",
"port": 8080
})
console.log("Listening on port 8080");
for await (const req of server) {
console.log(req.url);
const headers = new Headers();
headers.append("content-type", "application/json");
req.respond({
"headers": headers,
"body": JSON.stringify({"username": "HusseinNasser", "id": 1234})
})
}