Chapter 16 Web Pages And CGI Scripts Department of Biomedical Informatics University of Pittsburgh School of Medicine

Slides:



Advertisements
Similar presentations
Chapter 6 Server-side Programming: Java Servlets
Advertisements

PHP Form and File Handling
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Molecular Biomedical Informatics Web Programming 1.
DT228/3 Web Development WWW and Client server model.
CIS101 Introduction to Computing Week 08. Agenda Your questions JavaScript text Resume project HTML Project Six This week online Next class.
CGI Programming Part 2. Input Tags Many different ways of getting data from the user. The tag is used most often. has a type attribute –Specifies the.
JavaScript Forms Form Validation Cookies CGI Programs.
Python, CGI November 23, Unit 8. So Far We can write programs in Python (in theory at least) –Conditionals –Variables –While loops We can create a form.
 2002 Prentice Hall. All rights reserved. 1 Chapter 6 – Introduction to the Common Gateway Interface (CGI) Outline 6.1 Introduction 6.2 Client and Web.
How the web works: HTTP and CGI explained
Python and Web Programming
Crawler-Based Search Engine By: Bryan Chapman, Ryan Caplet, Morris Wright.
Using Entities & Creating Forms Jill R. Sommer Institute for Applied Linguistics Kent State University.
Python Web Applications A KISS Introduction. Web Applications with Python Fetching, parsing, text processing Database client – mySQL, etc., for building.
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.
Tutorial 6 Forms Section A - Working with Forms in JavaScript.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
CST JavaScript Validating Form Data with JavaScript.
1 ‘Dynamic’ Web Pages So far, we have developed ‘static’ web-pages, e.g., cv.html, repair.html and order.html. There is often a requirement to produce.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
Chapter 9 Using Perl for CGI Programming. Computation is required to support sophisticated web applications Computation can be done by the server or the.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
Lecture 6 – Form processing (Part 1) SFDV3011 – Advanced Web Development 1.
Forms and Form Controls Chapter What is a Form?
ITIS 1210 Introduction to Web-Based Information Systems Chapter 24 How Websites Work with Databases How Websites Work with Databases.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 35 – Python Outline 35.1 Introduction First Python Program Python Keywords 35.2 Basic.
1 HTML and CGI Scripting CSC8304 – Computing Environments for Bioinformatics - Lecture 10.
Tutorial 14 Working with Forms and Regular Expressions.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. Chapter 13 Files and Exception Handling 1.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
HTML II. Factors to consider in designing a website. Organizing your files. HTML Tables. Unordered Lists. Ordered Lists. HTML Forms. Learning Objectives.
Chapter 6 The World Wide Web. Web Pages Each page is an interactive multimedia publication It can include: text, graphics, music and videos Pages are.
GDT V5 Web Services. GDT V5 Web Services Doug Evans and Detlef Lexut GDT 2008 International User Conference August 10 – 13  Lake Las Vegas, Nevada GDT.
1 HTML Forms. 22 HTML forms provide a way for a user to send information back to the web server. Originally the user input was processed on the server.
CP476 Internet Computing CGI1 CGI is a common way to provide for specific computations on server side, interactions with users, or access to databases.
Python CGI programming
Introduction to Programming the WWW I CMSC Summer 2004 Lecture 6.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
USING PERL FOR CGI PROGRAMMING
Java CGI Lecture notes by Theodoros Anagnostopoulos.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
HTML Forms. Today’s Lecture We will try to understand the utility of forms on Web pages We will find out about the various components that are used in.
Website Development with PHP and MySQL Saving Data.
1 Basic Perl CGI Programming. 2 Issues How and when your program is invoked. Generating Response –HTTP Headers –HTML (or whatever document type you want)
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT.
ITCS373: Internet Technology Lecture 5: More HTML.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
XHTML & Forms. PHP and the WWW PHP and HTML forms – Forms are the main way users can interact with your PHP scrip Typical usage of the form tag in HTML.
Microsoft FrontPage 2003 Illustrated Complete Creating a Form.
Netprog 2002 CGI Programming1 CGI Programming CLIENT HTTP SERVER CGI Program http request http response setenv(), dup(), fork(), exec(),...
HTLM Forms CS3505. Form Handling in Browser html User Files out form WEbBROWSErWEbBROWSEr User read response submit Get URL?input html Get file html script.
Starting BBEdit or Notepad and Opening the HTML File Start BBEdit or Notepad Select Open from the File Menu Open survey1.htm from the Public Folder.
Interactive Web Tehcnologies Teppo Räisänen LIIKE/OAMK 2011.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
1 State and Session Management HTTP is a stateless protocol – it has no memory of prior connections and cannot distinguish one request from another. The.
HTML Forms. A form is simply an area that can contain form fields. Form fields are objects that allow the visitor to enter information - for example text.
Since you’ll need a place for the user to enter a search query. Every form must have these basic components: – The submission type defined with the method.
Creating Forms on a Web Page. 2 Introduction  Forms allow Web developers to collect visitor feedback  Forms create an environment that invites people.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
Learning Aim C.  In this section we will look at how text, tables, forms and frames can be used in web pages.
INTERNET APPLICATIONS CPIT405 Forms, Internal links, meta tags, search engine friendly websites.
Wrapping up our last topic: You and your (DNA) parasites Events like these, happening over and over again, have led to…
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.
Web Systems Development (CSC-215)
Integrating JavaScript and HTML
Presentation transcript:

Chapter 16 Web Pages And CGI Scripts Department of Biomedical Informatics University of Pittsburgh School of Medicine

The Content of this Lecture 1.Python web programming basics: 1) urllib2 module 2) cgi module 3) information for building your own web page at Pitt 2. Book tasks: 1) Grabing web pages 2) A simple CGI script for searching the neoplasm classification

urllib2 module The urllib2 module defines functions and classes which help in opening URLs. urllib2.Request() url should be a string containing a valid URL. urllib2.urlopen() The input of this function can be either a url string or a request object.

Examples >>> import urllib2 >>> req=urllib2.Request(url=' >>> f=urllib2.urlopen(req) >>> print f.read(100) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " >>>

Examples >>> f=urllib2.urlopen(' oinf2012') >>> print f.read(50) Index of /day/Bioinf2012/< >>>

urllib2 module exceptions urllib2.URLError.The handlers raise this exception when they run into a problem. It is a subclass of IOError. urllib2.HTTPError It is a subclass of URLError.

Algorithm for Grabbing Web Pages 1.Import the module that makes the HTTP requests (urllib2). 2.Make the HTTP request. 3.If the request returns the Web page, print the page. Otherwise, print an error message.

The cgi Module A CGI (Common Gateway Interface) script is invoked by an HTTP server, usually to process user input submitted through an HTML. The CGI module is used to implement CGI scripts. The contents of an HTML form are passed to a CGI program via a string which are accessed using the FieldStorage class of the CGI module.

The FieldStorage Class getvalue() is of member function of the the FieldStorage Class. This function returns the value of a given field with the fieldname as the input. For example: form = cgi.FieldStorage() message = form.getvalue("tx", "(no message)")

The cgitb mudule This module provides an exception handler that displays a detailed report. It is a good practice to include the follow statements when you develop a new cgi script: import cgitb cgitb.enable()

Information for Building Your Own Web Page at Pitt You can build your own Web site at Pitt. The instructions for doing this are contained in the following two files: afs_web.pdf Html_inst.pdf These two files were uploaded to our website.

A simple CGI script for searching the neoplasm classification 1.Create a very simple Web page consisting of a simple form (see the figure below). This form contains a text box and a “ submit” button for taking user input. The source code of this form should contain the URL (Universal Resource Locator, or Web address) linked to the folder (cgi-bin) where your CGI script can be found.

<form name="sender" method="GET" action=" bin/neopull.py">

A simple CGI script for searching the neoplasm classification 2.Upload the your Web page to a folder on a webserver, designated for this class. This folder will be publically accessible through the Web. 3.Create a script and upload it to another folder called cgi-bin on the webserver. The cgi-bin folder is also designated for the class. The web address of this folder will be the same as the address on the HTML source code of your Web page. In my example, it should be: "

A simple CGI script for searching the neoplasm classification 4.The algorithm of the script you will upload in step 3 starts at step 4. Capture the string sent by the user through your web page. Place the text into a string object (message).

form = cgi.FieldStorage() message = form.getvalue("tx", "(no message)") term_check = re.search(r'[A-Za-z ]+$', message) if not term_check: print " Only alphabetic letters and spaces are permitted in the query box" print " " sys.exit()

A simple CGI script for searching the neoplasm classification 5.Print out the HTML header of the web page that will be returned to the user. print " Your query term is " + message + " "

A simple CGI script for searching the neoplasm classification 6.Open up a file called “neoself” which contains the neoplasm classification information. 7. Go through each line of this file to look for the terms that match the “message” entered by the users. When a matched term is found, print the line that contained the term. 8. Print a line to acknowledge the user the work is done.

in_text = open("../data/neoself", "r") for line in in_text: query_match = re.search(message, line) if query_match: line = re.sub(r'\|'," ", line) print " " + line + " " exit