Molecular Biomedical Informatics Web Programming 1.

Slides:



Advertisements
Similar presentations
Web 2.0 Programming 1 © Tongji University, Computer Science and Technology. Web Web Programming Technology 2012.
Advertisements

© 2002 D & D Enterprises 1 Linking Images For Navigation & Clickable Image Maps.
IS 6116 Introduction – 10 Jan Lecturer Details Aonghus Sugrue Website: aonghussugrue.wordpress.com
Copyright © 2003 Pearson Education, Inc. Slide 7-1 The Web Wizards Guide to PHP by David Lash.
J0 1 Marco Ronchetti - The Web: an architectural view.
1 Applets Programming Enabling Application Delivery Via the Web.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizards Guide to PHP by David Lash.
1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 2 Getting Started.
1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Using Perl for CGI Programming.
1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 4 Working with the Web.
Nick Feamster CS 6262 Spring 2009
4 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: Servlets.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
Addition Facts
Molecular Biomedical Informatics Web Programming 1.
4. Internet Programming ENG224 INFORMATION TECHNOLOGY – Part I
Social Web Design 1 Darby Chang Social Web Design.
Web Programming 1 Darby Chang Web Programming. Cookie 2 Web Programming.
Molecular Biomedical Informatics Web Programming 1.
Social Web Design 1 Darby Chang Social Web Design.
1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
CS 22: Enhanced Web Site Design - Week 8Slide 1 of 15 Enhanced Web Site Design Stanford University Continuing Studies CS 22 Mark Branom
1 Server Side Includes and cgi scripts Advanced Web Programming.
Addition 1’s to 20.
25 seconds left…...
Services Course Windows Live SkyDrive Participant Guide.
Week 1.
We will resume in: 25 Minutes.
CHAPTER 11 FILE INPUT & OUTPUT Introduction to Computer Science Using Ruby (c) 2012 Ophir Frieder et al.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 14: Protection.
1/16 Steven Leung Introduction to HTML/CGI/JavaScript Intro to HTML/CGI/JavaScript How the Web Works HTML: Basic Concept CGI: Basic Concept JavaScript:
Presenter: James Huang Date: Sept. 29,  HTTP and WWW  Bottle Web Framework  Request Routing  Sending Static Files  Handling HTML  HTTP Errors.
Molecular Biomedical Informatics 分子生醫資訊實驗室 Web Programming 網際網路程式設計 1.
HTML Concepts and Techniques Fourth Edition Project 2 Creating and Editing a Web Page.
Adding Dynamic Content to your Web Site
1 CGICGI Common Gateway Interface Server-side Programming Lecture.
Ruby (on Rails) CSE 190M, Spring 2009 Week 3. Web Programming in Ruby Ruby can be used to write dynamic web pages Similar to PHP, chunks of Ruby begins.
DT228/3 Web Development WWW and Client server model.
Molecular Biomedical Informatics 分子生醫資訊實驗室 Web Programming 網際網路程式設計 1.
Server-Side vs. Client-Side Scripting Languages
Guide To UNIX Using Linux Third Edition
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
Chapter 6: Hostile Code Guide to Computer Network Security.
CGI Programming Languages Web Based Software Development July 21, 2005 Song, JaeHa.
CGI Common Gateway Interface. CGI is the scheme to interface other programs to the Web Server.
UFCEKG-20-2 Data, Schemas & Applications Lecture 4 Server Side Scripting & PHP.
Python Mini-Course University of Oklahoma Department of Psychology Day 1 – Lesson 2 Fundamentals of Programming Languages 4/5/09 Python Mini-Course: Day.
1 Creating Web Forms in HTML Web forms collect information from customers Web forms include different control elements including: –Input boxes –Selection.
2 1 Sending Data Using a Hyperlink CGI/Perl Programming By Diane Zak.
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
CGI Common Gateway Interface. CGI is the scheme to interface other programs to the Web Server.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
JSP BASICS AND ARCHITECTURE. Goals of JSP Simplify Creation of dynamic pages. Separate Dynamic and Static content.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
 2001 Prentice Hall, Inc. All rights reserved. Chapter 7 - Introduction to Common Gateway Interface (CGI) Outline 7.1Introduction 7.2A Simple HTTP Transaction.
Form Processing Week Four. Form Processing Concepts The principal tool used to process Web forms stored on UNIX servers is a CGI (Common Gateway Interface)
Chapter 16 Web Pages And CGI Scripts Department of Biomedical Informatics University of Pittsburgh School of Medicine
How CGI and Java Servlets are Run By David Stein 14 November 2006.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
Lesson 11. CGI CGI is the interface between a Web page or browser and a Web server that is running a certain program/script. The CGI (Common Gateway Interface)
University of Kansas Department of Electrical Engineering and Computer Science Dr. Susan Gauch April 21, 2005 I T T C Introduction to Web Technologies.
CS 330 Class 7 Comments on Exam Programming plan for today:
Scripting Languages Info derived largely from Programming Language Pragmatics, by Michael Scott.
Programming Basics Web Programming.
Web Application Development Using PHP
Presentation transcript:

Molecular Biomedical Informatics Web Programming 1

CGI 2 Web Programming

Common Gateway Interface (CGI) Common – Gateway – Interface – Web Programming 3

4

Its an interface It allows browsers (and thus users) to communicate with web servers –In brief, an interface is a bulk of rules. If you program follows these rules, you can communicate with browsers. A program that fits these rules is called a CGI program. –CGI is over HTTP A CGI program is just a program where the only thing need to know is how its IO related to browsers IO Web Programming 5 Browser CGI Program Web Server HTML FormEnvironment Standard OutputHTML

HTML form Passing data to the server side Boy Girl Submit HTML Forms and Input You know HTML, and thus you know the browsers' IO Web Programming 6

CGI program CGI is not a language. If you follow the rules, you can use any programming language to implement a CGI program. But please dont try any… –Perl is a widely used language in CGI programming. In addition to Perl, shell script, Python, Ruby, PHP, Tcl, C/C++ and Visual Basic can be used for CGI programming by - - Web Programming 7

CGI IO in Perl # input use CGI; my $cgi = new CGI; my $nick = $cgi->param('nick'); my $color = $cgi->param('color'); # output print "Content-type: text/html\n\n"; # HTTP header print "Hello World! "; # any valid HTML print "$nick likes $color!"; # any valid HTML Easy? Lets see other languages Web Programming 8

CGI IO in PHP Hello World! Web Programming 9

CGI IO in JSP Hello World! Web Programming 10

CGI IO in C #include #include int main(void) { // input char * query; char nick[256], color[256]; // dangerous data = getenv('QUERY_STRING'); sscanf(query, "nick=%s&color=%s", &nick, &color); // output printf("Content-type: text/html\n\n"); // HTTP header printf("Hello World! "); // any valid HTML printf("%s likes %s!", nick, color); # any valid HTML return 0; } UNIX > CGI C UNIX > CGI C So just dont use it Web Programming 11

12 You may change the content types, but how? Web Programming

Test (debug) CGI programs Pass input data via the URL &color=blue Actually, browsers do the same thing while submitting a HTML form Web Programming 13

Web Programming 14

Perl Script language The most advantages are string manipulation and hash The first line must be –#!/usr/bin/perl -w use strict; –be sure to include this line –Perl is an untyped ( ) language where variables can be used without declaration, but the harm is larger (bugs) than the convenience You can use any language such as PHP, but try to prevent using C/C++ for CGI programming –native support, string manipulation, protection… –Perl can call C/C++ programs Web Programming 15

File IO in Perl open FH, 'res/member' or die; # open a file while ( ) { # each line chomp; # truncate the last "\n" character my ( $_name, $_nick ) = split "\t"; # split by tab $_nick eq $nick and $name = $_name and last; # compare } close FH; # close the file $_ = `/bin/cat _hello.html`; # use Linux command s/{name}/$name/g; # replace print "Content-type: text/html\n\n$_"; # output The magic $_ variable –using it well will largely reduce the code (but less readable for rookies) Sometime Perl looks like English Call outer programs/commands The concept of template ( ) Web Programming 16

Some tips Set CGI programs to executable –$ chmod 755 do You may debug as a Perl program –$./do # remember to fix the input There is a module to help output error messages to browser –use CGI::Carp "fatalsToBrowser"; Writable file –$ chmod 666 filename # make it writable to web server –open FH, ">filename" or die; –open FH, ">>filename" or die; Web Programming 17

Script/interpreted languages Interpreted Languages: PHP, Perl, Python, Ruby (Sheet One) Interpreted Languages: PHP, Perl, Python, Ruby (Sheet One) Interpreted Languages: PHP, Perl, Python, Ruby (Sheet Two) Interpreted Languages: PHP, Perl, Python, Ruby (Sheet Two) Web Programming 18

Any Questions? Web Programming 19

Todays assignment Web Programming 20

Make your web site memorable Implement at least one cross-computer (namely you cannot implement with only JavaScript) interaction with CGI Reference –Perl Perl –Perl - Perl - Your web site ( will be checked not before 23:59 11/4 (Sun). You may send a report (such as some important modifications) to me in case I did not notice your features. me Web Programming 21

Appendix 22 Web Programming

If we have time… Im sure that we wont have spare time today :p We wont have enough time to finish Perl in the whole semester so that I can only teach specific functions But Im not sure what functions you need, so please think about it and feel free to discuss with me via any media Web Programming 23