Guest User

Untitled

a guest
Jan 17th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. test/
  2. server.js
  3. node_modules/
  4. ...
  5. public/
  6. client.html
  7. stylesheet.css
  8.  
  9. var http = require("http");
  10. var fs = require("fs");
  11.  
  12. function send404(response){
  13. console.log("There was an error!")
  14. response.writeHead(404, {"Content-Type": "text/plain"});
  15. response.write("Error 404: resource not found");
  16. response.end();
  17. }
  18.  
  19. var server = http.createServer(function(req, res){
  20. if (req.url === "/"){
  21. filePath = "public/client.html";
  22. } else {
  23. filePath = "public" + req.url;
  24. }
  25. var absPath = "./" + filePath;
  26.  
  27. fs.readFile(absPath, function(err, data){
  28. if (err) {
  29. send404(res);
  30. } else {
  31. switch (req.url) {
  32. case "/stylesheet.css":
  33. res.writeHead(200, {"content-type": "text/css"});
  34. default:
  35. res.writeHead(200, {"content-type": "text/html"});
  36. }
  37. res.end(data);
  38. }
  39. });
  40. }).listen(9000);
  41.  
  42. <!DOCTYPE HTML>
  43.  
  44. <html lang="en">
  45.  
  46. <head>
  47. <meta charset='utf-8' />
  48. <link rel='stylesheet' type='text/css' href='stylesheet.css'/>
  49. <title>Experiment test</title>
  50. </head>
  51.  
  52. <body>
  53.  
  54. <div id='progress_bar'><div id='progress'></div></div>
  55.  
  56. <div id='entryId'>
  57. <button id='submitId'>NEXT</button>
  58. </div>
  59.  
  60. </body>
  61.  
  62. </html>
  63.  
  64. html,body{
  65. font-family: 'Arial', sans-serif;
  66. background-color: white;
  67. }
  68.  
  69. button{
  70. height: 50px;
  71. width: 150px;
  72. font-size: 25px;
  73. color: white;
  74. border: none;
  75. border-radius: 5px;
  76. background-color: #03A7FF;
  77. letter-spacing: 1px;
  78. cursor: pointer;
  79. }
Add Comment
Please, Sign In to add comment