Giter Club home page Giter Club logo

node-server's Introduction

node-http-file-server

In this exercise, you'll use the fs module and the http module to create an HTTP file server.

Setup

  • Fork and clone this repository. A skeleton server has been defined for you in server.js and should serve as the basis for your application.
  • Start your server with the command node server.js.

Instructions

  • Open a browser to localhost:8000.
  • You should see the greeting, "Hello, World!"
  • Add code inside of handleRequest that will display the phrase "I can change the response."
  • Open a browser to localhost:8000 and view the updated text.
  • Add a file named about.html to your repository.
  • Add inside of about.html the text "I'm a response inside of a file!"
  • Require the fs module inside of server.js
  • Use the fs module to serve about.html when visiting http://localhost:8000/about.html.
  • Repeat what you did with about.html and do the same for a file named faq.html.

Bonus

  • Add an anchor tags that connect both pages. about.html, for instance, should include a link to faq.html and vice versa.
  • Create a third page named index.html. This page should include anchor tags to about.html and faq.html.
  • Serve index.html when visiting http://localhost:1337
  • Add CSS to all pages.
  • Create a 404 Not Found page for any route that's not /, /about.html, or /faq.html. You could use an appropriate image from cat status codes.
  • Refactor your code to find a general way to handle requests for all files in this directory. For instance, remove the routes from server.js and place them in a file named routes.js.

node-server's People

Contributors

amk-boco avatar choskim avatar eddyk92 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.