moved folder structure
This commit is contained in:
38
tests/tests_hugo/pure_node/server.js
Normal file
38
tests/tests_hugo/pure_node/server.js
Normal file
@@ -0,0 +1,38 @@
|
||||
const http = require('http')
|
||||
const fs = require('fs')
|
||||
const url = require('url')
|
||||
|
||||
const sendMyFile = (file, res) => {
|
||||
fs.readFile(file, (err, data) => {
|
||||
if (!err) {
|
||||
res.writeHead(200, {
|
||||
'content-type': 'text/html; charset=utf-8'
|
||||
})
|
||||
res.end(data)
|
||||
}
|
||||
else
|
||||
res.writeHead(404).end('file not found')
|
||||
})
|
||||
}
|
||||
|
||||
const server = http.createServer((req, res) => {
|
||||
|
||||
let pathName = url.parse(req.url).pathname
|
||||
|
||||
if (req.method === "GET") {
|
||||
if (pathName === "/")
|
||||
sendMyFile("index.html", res)
|
||||
else if (pathName === "/index.html")
|
||||
sendMyFile("index.html", res)
|
||||
else
|
||||
res.writeHead(404).end('wrong url')
|
||||
}
|
||||
})
|
||||
|
||||
server.get('/', (req, res) => {
|
||||
res.sendFile(__dirname + "/" + "index.html")
|
||||
})
|
||||
|
||||
const port = 3000
|
||||
server.listen(port, console.log(`listening on port ${port} with express`));
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
//const http = require('http')
|
||||
//const fs = require('fs')
|
||||
//const url = require('url')
|
||||
|
||||
const express = require('express')
|
||||
const server = express()
|
||||
|
||||
server.get('/', (req, res) => {
|
||||
res.sendFile(__dirname + "/" + "index.html")
|
||||
})
|
||||
|
||||
//const sendMyFile = (file, res) => {
|
||||
// fs.readFile(file, (err, data) => {
|
||||
// if (!err) {
|
||||
// res.writeHead(200, {
|
||||
// 'content-type': 'text/html; charset=utf-8'
|
||||
// })
|
||||
// res.end(data)
|
||||
// }
|
||||
// else
|
||||
// res.writeHead(404).end('file not found')
|
||||
// })
|
||||
//}
|
||||
//
|
||||
//const server = http.createServer((req, res) => {
|
||||
//
|
||||
// let pathName = url.parse(req.url).pathname
|
||||
//
|
||||
// if (req.method === "GET") {
|
||||
// if (pathName === "/")
|
||||
// sendMyFile("index.html", res)
|
||||
// else if (pathName === "/index.html")
|
||||
// sendMyFile("index.html", res)
|
||||
// else
|
||||
// res.writeHead(404).end('wrong url')
|
||||
// }
|
||||
//})
|
||||
|
||||
const port = 3000
|
||||
server.listen(port, console.log(`listening on port ${port} with express`));
|
||||
|
||||
9
tests/tests_hugo/with_express/index.html
Normal file
9
tests/tests_hugo/with_express/index.html
Normal file
@@ -0,0 +1,9 @@
|
||||
<!Doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>title</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>hello world</h1>
|
||||
</body>
|
||||
</html>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user