Array
University of Oregon

Hello, HTTP!

HTTP Protocol

A. HTTP is Stateless & Anonymous
B. Request Methods (Get, Post, …)
C. Request Headers


Hello, HTTP!

  1. Create a new directory, ~/Documents/repos/281/examples/http/.
  2. cd to http, and create a subdirectory named app.
  3. cd to the app directory.
  4. Download server.js to the app directory.
  5. Open server.js in Atom.

    The function that’s passed to createServer is called once for every HTTP request that’s made against that server, so it’s called the request handler.

    When an HTTP request hits the server, node calls the request handler function with two handy objects for dealing with the transaction, request and response.

    In order to actually serve requests, the listen method needs to be called on the server object. All you pass to listen is the port number to listen to.

  6. Start the server with this command:
     $ node server.js
  7. Open either of the following URLs in Chrome:
     http://127.0.0.1:3000/
    
     http://localhost:3000/
  8. Stop the server with the Unix interrupt command: control-c.

Web API Programming

The API economy’s growth is driven by service providers that compete by packaging complex data and functionality into easily reused API-based components called services.

Developers can use APIs to access services offered by remote systems. For example, a ride-hailing app (Taxis, Lyft, Uber) can call a credit card processing API like Stripe.

APIs are often referred to as an engine of innovation. The Google Maps API is just one API that spawned a cycle of innovation that continues to this day.

Instagram might not exist without the Facebook API that allows Instagram users to post their latest photos to Facebook.

  • Why Did They Put the Web in Web APIs?

    The Web as an Application Platform: To the extent that Web or mobile applications are primarily composed from calls to multiple Web APIs, the Web has turned into a programmable platform that’s equally, if not more, powerful than the Windows, Mac and Linux platforms.

  • The API Economy
Skip to toolbar