Showing
1 changed file
with
0 additions
and
43 deletions
base.js
deleted
100644 → 0
1 | -var http = require('http'); | ||
2 | -var fs = require('fs'); | ||
3 | -var url = require('url'); | ||
4 | - | ||
5 | -var app = http.createServer(function(request,response){ | ||
6 | - var _url = request.url; | ||
7 | - var queryData = url.parse(_url, true).query; | ||
8 | - if(_url == '/'){ | ||
9 | - _url = '/Index.html'; | ||
10 | - } | ||
11 | - if(_url == '/favicon.ico'){ | ||
12 | - return response.writeHead(404); | ||
13 | - } | ||
14 | - response.writeHead(200); | ||
15 | - console.log(queryData.busNum); | ||
16 | - | ||
17 | - if (queryData.busNum != null){ // 버스번호를 요청했을때 타임테이블 페이지로 전환 | ||
18 | - var timetableHTML = ` | ||
19 | -<!doctype html> | ||
20 | -<html> | ||
21 | -<head> | ||
22 | - <title>Time Table</title> | ||
23 | - <meta charset="utf-8"> | ||
24 | - <style type="text/css"> | ||
25 | - a { text-decoration:none } | ||
26 | - </style> | ||
27 | -</head> | ||
28 | - | ||
29 | -<body> | ||
30 | - <h1><a href="Index.html"><p style="text-align:center;">BTT</p></a></h1> | ||
31 | - <br> | ||
32 | - <h2>${queryData.busNum} BUS Time Table</h2> | ||
33 | - <p> Response from API server ... </p> | ||
34 | -</body> | ||
35 | -</html> | ||
36 | - `; | ||
37 | - response.end(timetableHTML); | ||
38 | - } | ||
39 | - else{ // 아니라면, url 따라감 | ||
40 | - response.end(fs.readFileSync(__dirname + _url)); | ||
41 | - } | ||
42 | -}); | ||
43 | -app.listen(23023); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment