Common Gateway Interface

4th lecture, May 6, 2019

Projects in Information Technology II

http://www.sw.it.aoyama.ac.jp/2019/Projects2/lecture4.html

Martin J. Dürst

AGU

© 2019 Martin J. Dürst 青山学院大学

ミニテスト

 

Today's Schedule

 

How to Be Successful in this Course

 

Last Lecture's Exercises

Exercise 3a: Calendar Conversion

Exercise 3b: Temperature Conversion

Homework

 

Course Overview

  

Loop Example

(1..5).each do |n|
    puts n
end

 

Range

 

Loops in Ruby

 

Ruby Blocks

 

More Loop Examples

(1..5).each  { |n| puts n }

(1..5).each  { |i| puts i }

(1..5).each  { |n| puts n+3, n*3 }

(1..10).each { |n| puts n }

(1...5).each { |n| puts n }

(1..5).each do |n| puts n end

[2,3,5,7,11].each { |n| puts n }

[1,2,4,8].each { |n| puts n**n }

Many of these examples use Ranges, but use on Arrays is even more common.

 

Iterator Demo

 

Dynamic Web Sites

 

CGI Basics

 

How CGI Works

---------------               --------------------------------------
| client      |               |             server machine         |      
| machine     |               |                                    |
|             | (1)           |              (2) set ENV           |
| ----------- | HTTP request  | ------------ call script --------- |
| |         |------------------>|          |------------>|       | |
| | client  | |               | |Web server|             | CGI   | |
| |(browser)| |               | |(webrick) |             | script| |
| |         |<------------------|          |<------------|       | |
| ----------- | HTTP response | ------------ (3) stdout  --------- |
--------------- (4)           --------------------------------------

 

CGI Input and Output

 

Web Servers

 

CGI Demo

 

CGI Security

 

More on Ruby Output

 

Exercise 4a: A Program to Convert Marks

 

Exercise 4b: A Web Page to Convert Marks

 

Exercise 4c: A CGI Script to Convert Marks

 

Exercise 4d: Advanced Exercise (発展問題):
An Advanced CGI Script to Convert Marks

  

Homework