Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- test/
- server.js
- node_modules/
- ...
- public/
- client.html
- stylesheet.css
- var http = require("http");
- var fs = require("fs");
- function send404(response){
- console.log("There was an error!")
- response.writeHead(404, {"Content-Type": "text/plain"});
- response.write("Error 404: resource not found");
- response.end();
- }
- var server = http.createServer(function(req, res){
- if (req.url === "/"){
- filePath = "public/client.html";
- } else {
- filePath = "public" + req.url;
- }
- var absPath = "./" + filePath;
- fs.readFile(absPath, function(err, data){
- if (err) {
- send404(res);
- } else {
- switch (req.url) {
- case "/stylesheet.css":
- res.writeHead(200, {"content-type": "text/css"});
- default:
- res.writeHead(200, {"content-type": "text/html"});
- }
- res.end(data);
- }
- });
- }).listen(9000);
- <!DOCTYPE HTML>
- <html lang="en">
- <head>
- <meta charset='utf-8' />
- <link rel='stylesheet' type='text/css' href='stylesheet.css'/>
- <title>Experiment test</title>
- </head>
- <body>
- <div id='progress_bar'><div id='progress'></div></div>
- <div id='entryId'>
- <button id='submitId'>NEXT</button>
- </div>
- </body>
- </html>
- html,body{
- font-family: 'Arial', sans-serif;
- background-color: white;
- }
- button{
- height: 50px;
- width: 150px;
- font-size: 25px;
- color: white;
- border: none;
- border-radius: 5px;
- background-color: #03A7FF;
- letter-spacing: 1px;
- cursor: pointer;
- }
Add Comment
Please, Sign In to add comment