Personal blog written from scratch using Node.js, Bootstrap, and MySQL. https://jrtechs.net
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
991 B

  1. /**
  2. * Main server file for the blog. This file is responsible for
  3. * creating the server and listening for clients. The main run
  4. * function parses the url and calls a sub module to make the
  5. * appropriate pages.
  6. */
  7. const http = require('http');
  8. const url = require('url');
  9. const includes = require('./includes/includes.js');
  10. http.createServer(function (request_url, res)
  11. {
  12. var q = url.parse(request_url.url, true);
  13. var filename = q.pathname;
  14. //prints header
  15. includes.printHeader(res);
  16. if(filename.includes("/category"))
  17. {
  18. //categories or view a category page
  19. }
  20. else if(filename.includes("/downloads/"))
  21. {
  22. //downloads page
  23. //probably will be implemented later
  24. }
  25. else if(filename.includes("/admin"))
  26. {
  27. //admin page
  28. }
  29. else
  30. {
  31. //normal blog entry
  32. require("./posts/posts.js").main(res, filename);
  33. }
  34. //includes footer file
  35. includes.printFooter(res);
  36. }).listen(8080);