forked from ccc112a/ws112a
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hw1.js
38 lines (34 loc) · 872 Bytes
/
hw1.js
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
26
27
28
29
30
31
32
33
34
35
36
37
38
import { Application} from "https://deno.land/x/oak/mod.ts";
const app = new Application();
app.use(async (ctx) => {
console.log('path=', ctx.request.url.pathname);
ctx.response.body = `
<html>
<body>
</body>
</html>`
if(ctx.request.url.pathname==`/nqu`){
ctx.response.body = `
<html>
<body>
<a href="https://www.nqu.edu.tw/">NQU</a>
</body>
</html>`
}
else if(ctx.request.url.pathname==`/nqu/csie`){
ctx.response.body = `
<html>
<body>
<a href="https://csie.nqu.edu.tw/">NQU/CSIE</a>
</body>
</html>`
}
else if(ctx.request.url.pathname==`/to/nqu`){
ctx.response.redirect('https://www.nqu.edu.tw/')
}
else if(ctx.request.url.pathname==`/to/nqu/csie`){
ctx.response.redirect('https://csie.nqu.edu.tw/')
}
});
console.log('start at : http://127.0.0.1:8000')
await app.listen({ port: 8000 });