Code Monkey home page Code Monkey logo

exercises-js-express-sandbox's Introduction

Express Sandbox

Let's build our first dynamic web application! We'll be using the Express framework, a lightweight way to write web application

Contents

What A Web Application Is

Originally, the web was invented to share hypertext documents, mostly among academics. People would write HTML files โ€” HTML stands for Hypertext Markup Language โ€” and serve them up using a simple document server (called a web server). Users would navigate between web servers using a browser, a special piece of software that could turn HTML into something graphical and clickable.

Web browsers and web servers communicate using HTTP, the Hypertext Transfer Protocol.

A web application is a program that listens for incoming HTTP requests and responds with a programmatically-generated HTML document.

Getting Started

  1. Fork this repository
  2. Use git clone to get a local copy of your fork
  3. Run npm install inside the project directory
  4. Run npm start to start the web application
  5. Navigate to http://localhost:3000
  6. Start on the iterations

Remember, you have to run npm install before any of this will work.

Errors And Restarting The Web Server

  1. You can restart the web server by pressing Ctrl+C in the terminal where the web server is running.

  2. If you see an error involving EADDRINUSE that means you're already running the web server somewhere. You have to kill that copy of the server.

    To do that, run the following:

    ps aux | grep app.js

    You should see a line that contains node app.js, like this:

    jesse            40313   0.0  0.1  4571396  24564 s000  S+    8:26AM   0:00.15 node app.js

    The second column is the process ID. Run the following to kill that process:

    kill 40313

Iterations

[v0] Explore

Before you write any code, get the web server running and visit http://localhost:3000. Click around and explore. When you visit a page, look at app.js and see what the web application is doing.

Pay attention to how the web application...

  • Knows which block of code to run
  • Creates the HTML document
  • Sends the HTML document back to the browser

[v1] Greeting Page (URL Only)

Make sure you understand how the web application handles /bake before attempting this.

  • As a user, when I visit /greet?name=WXYZ, I see a message greeting WXYZ. WXYZ could be any string, e.g., /greet?name=Jesse, /greet?name=Wilfred.
  • As a user, when I visit /greet, I see a message telling me there's no greeting to give.

[v2] Greeting Page (Form)

(Again, look at the form on /bake) to see how it works.

  • As a user, when I visit /greet (with or without parameters), I see a form that allows me to enter a name and submit to see a new greeting.

[v3] Your Own Page

Add your own page that has dynamic behavior. Servers can read/write to files, so maybe think of information you want to remember between page loads.

For example, you could read the contents of a todos.txt and display a list on the page.

Or, you could display the current time.

Or, you could keep track of how many people visited the page.

Or, you could use the data in the URL to dynamically set the styles on the page. Maybe change the background color or the typeface?

exercises-js-express-sandbox's People

Contributors

jfarmer 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.