Server-Side Scripting/Internet Data

From Wikiversity
Jump to navigation Jump to search

This lesson introduces Internet-based JSON data source processing.

Objectives and Skills[edit | edit source]

Objectives and skills for this lesson include:

  • Understand Internet data sources
  • Understand JSON, XML, and REST concepts
  • Process JSON data sources using server-side scripts

Readings[edit | edit source]

  1. Wikipedia: JSON
  2. Wikipedia: XML
  3. Wikipedia: Representational state transfer

Multimedia[edit | edit source]

Additional items will be contributed by course participants

Examples[edit | edit source]

JSON data for these examples comes from Wikidata: Countries and Temperatures.

Activities[edit | edit source]

Complete the following activities using HTML, CSS, and a server-side scripting language. Apply best practices for user interface design and your selected scripting language, including modules, comments, indentations, naming conventions, and constants. Use HTML forms, Internet-based JSON data sources for input, server-side scripts for processing, and HTML elements for output. Use separate functions for each type of processing. Avoid global variables by passing parameters and returning results. Add comments at the top of the code modules and include references to any resources used. Add the completed code to your website as /lesson8. For each activity, use the given Wikidata link as the JSON data source.

  1. Review Wikipedia: Saffir–Simpson scale and Wikidata: Tropical Cyclones and Maximum Sustained Winds. Create an application that reads the JSON data source containing dates, storm names, and maximum sustained winds in kilometers per hour. Build an array of dictionaries to hold the storm data. Display the data sorted by storm intensity in decreasing order. For each storm, display the maximum sustained winds in miles per hour, kilometers per hour, and the Saffir-Simpson scale category for the storm. Use CSS formatting to color-code the data based on storm category, similar to Wikipedia:Template:Saffir-Simpson scale.
  2. Review Wikipedia: Moment magnitude scale and Wikidata: Earthquakes and Moment Magnitudes Since 2000 C.E.. Create an application that reads the JSON data source containing dates, earthquake names, and moment magnitudes. Build an array of dictionaries to hold the earthquake data. Display the data sorted by earthquake intensity in decreasing order. For each earthquake, display the earthquake name, moment magnitude, and a magnitude description. See Wikipedia:Richter magnitude scale#Richter magnitudes for magnitude description ranges (Micro, Minor, Light, etc.). Use CSS formatting to color-code the data based on magnitude description.
  3. Review Wikipedia:Wildfire and Wikidata: Wildfires and Area. Create an application that reads the JSON data source containing dates, wildfires, and area impacted. Build an array of dictionaries to hold the wildfire data. Display the wildfire information in decreasing order of impact. Use CSS formatting to color-code the data based on the order of magnitude of area impacted (1, 10, 100, 1,000, etc.).
  4. Review Wikipedia:Tsunami and Wikidata: Tsunamis by Date. Create an application that reads the JSON data source containing dates, tsunamis, continents, and countries. Build an array of dictionaries to hold the tsunami data. Display the tsunami information in alphabetical order by continent and country. Use CSS formatting to color-code the data based on continent.

Lesson Summary[edit | edit source]

Additional items will be contributed by course participants

  • RESTful applications will use a stateless protocol. For this session, we are using a uniform interface for resource identification (XML, JSON).[1]

Key Terms[edit | edit source]

Additional items will be contributed by course participants

JSON (JavaScript Object Notation)
A lightweight data-interchange format, built on two structures. A collection of name/value (dictionary) pairs and an ordered list of values (array).[2]

See Also[edit | edit source]

References[edit | edit source]