Server-Side Scripting/Strings and Files

This lesson introduces string and uploaded file processing.

Objectives and Skills
Objectives and skills for this lesson include:
 * Understand string processing
 * Understand file processing
 * Upload files to server-side scripts
 * Process text files using server-side scripts

Readings

 * 1)  String (computer science)
 * 2)  Computer file
 * 3)  Upload

Multimedia

 * 1) YouTube: Go Simple HTTP File Upload Tutorial
 * 2) YouTube: How To Upload Files With Node.js
 * 3) YouTube: PHP File Upload
 * 4) YouTube: Uploading files with Flask

Examples
A data file for these examples may be downloaded from Wikidata: Countries and Temperatures. Select the hidden Wikidata right toolbar and  /.


 * /Go/
 * /Node.js (Express)/
 * /PHP/
 * /Python (FastAPI)/
 * /Python (Flask)/

Activities
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, input elements, and text files 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. For each activity, sample test data may be downloaded from the Wikidata link using the Wikidata hidden right toolbar and selecting  /.
 * 1) Review  Saffir–Simpson scale and Wikidata: Tropical Cyclones and Maximum Sustained Winds. Create an application that allows the user to select and upload a comma-separated-values file containing dates, storm names, and maximum sustained winds in kilometers per hour. 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  Moment magnitude scale and Wikidata: Earthquakes and Moment Magnitudes Since 2000 C.E.. Create an application that allows the user to select and upload a comma-separated-values file containing dates, earthquake names, and moment magnitudes. For each earthquake, display the earthquake name, moment magnitude, and a magnitude description. See Richter magnitude scale for magnitude description ranges (Micro, Minor, Light, etc.).  Use CSS formatting to color-code the data based on magnitude description.
 * 3) Review Wildfire and Wikidata: Wildfires and Area. Create an application that allows the user to select and upload a comma-separated-values file containing dates, wildfires, and area impacted. Display the wildfire information. 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 Tsunami and Wikidata: Tsunamis by Date. Create an application that allows the user to select and upload a comma-separated-values file containing dates, tsunamis, continents, and countries. Display the tsunami information. Use CSS formatting to color-code the data based on continent.

Lesson Summary
Additional items may be contributed by course participants
 * Strings are a series of characters used by a computer program. Strings are implemented differently in different programming languages. They can be null-terminated, or byte- and bit- terminated, or defined with a prefix length. Most languages allow for different string manipulation like concatenating strings together or splitting them apart into substrings. It is beneficial to become familiar with some string manipulation options available in the language you are working.
 * Files can be uploaded to a server and processed as a typical client-server model. Files can also be transferred between two remote systems by another local system which is known as remote uploading.
 * Express requires the use of specific middleware for uploading files.

Key Terms
Additional items may be contributed by course participants


 * Comma Separated Values (CSV) file
 * A text file that, as its name says, contains values separated by commas. It simulates a table, where each row is a new line and each column is separated by a comma.


 * data file
 * A computer file which stores data to be used by a computer application or system, including input and output data. Data files do not usually contain executable code.


 * enctype
 * An HTML form attribute that specifies how the form-data should be encoded when submitting it to the server.


 * &lt;input type="file"&gt;
 * &lt;input&gt; elements with type="file" let the user choose one or more files from their device storage. Once chosen, the files can be uploaded to a server using form submission, or manipulated using JavaScript code and the File API.


 * multipart/form-data
 * multipart/form-data is a value of enctype attribute. The multi-part means form data divides into multiple parts and send to a server.


 * parser
 * A software component that takes input data (frequently text) and builds a data structure - often some kind of parse tree, abstract syntax tree or other hierarchical structure, giving a structural representation of the input while checking for correct syntax.


 * string
 * A data type that is a sequence of characters, though they look like plain text they are typically an array where the indices represent the individual characters. They are useful for holding data that can be represented in text form.


 * upload
 * Transmission of a file from one computer system to another, usually a larger computer system.