Cs.newpaltz.edu



Web Programming & Web-Based Systems How WWW worksHTML basicsPython basicsBe able to create a simple web page at your CS accountHow CGI works Try to create a simple CGI-based web page at your CS account+CS Web Server address(Used for PUTTY, WINSCP, … ): wyvern.cs.newpaltz.edu+TEXT editor in CS system:jpico index.htm+ERROR log is at:tail /var/log/httpd/error_log+Go to MySQL account:mysql -h localhost –pUSE YourUseName_db;MySQL accounts: The username is the students NPCUID. The database name is the username followed by "_db"The initial passwords were set to a random character string consisting of numbers and lower case letters.? The string length is 6.? These passwords were mailed to the students HawkMail addresses. 1. How WWW works ?0185420Client-side Web Programming: write programs which run within browsers to display web pages. Server-side Web Programming: write programs which run at the web server site to process requests/data and produce codes for web pages.HTTPHypertext Transfer Protocol?(HTTP) is an?application protocol?for distributed, collaborative,?hypermedia?information systems. Hypertext?is structured text that uses logical links (hyperlinks) between?nodes?containing text. HTTP is the protocol to exchange or transfer hypertext.2. HTML basics HTML or HyperText Markup Language is the standard markup language used to create Web pages.a HTML code/program runs within a Web browser. The output of running that code is the web page which users can see.A language for info presentation (later add -> info storage)018224500You can learn more about HTML at . PYTHON basicsEasy, for programming beginnersInterpreted(no pre-compilation), OOP and interactiveSimilar to Perl and PHPYou can learn more about PYTHON at . Create web pages at your CS accountUSE a TEXT EDITOR program (jpico) to create and edit files: >jpico index.html5. How CGI works ? Common Gateway Interface (CGI) is a method for generating dynamic contents of web pages. CGI programs/scripts are programs(applications) which resides and run at the server site, they:get inputs from web browser (via forms) and produces output/response (HTML code) at the server site. Then, the HTML output will be sent automatically back to the web browser, run there and display the results to users.So, what it takes to build and make a CGI program works ? You will need more than just one program.HTML code to display the FORM to the users (to input INFO)CGI program which will produce another HTML code (to display results)Although, it is only TWO programs but since the CGI program must produce another HTML code/output, you will need to define that HTML output (which is a program) first. So, at the end it is actually THREE programs:HTML code to display the FORM to the users (to input INFO)HTML output (to display RESULTS)CGI program which processes the INFO from the FORM (via EV) and produce the HTML output above.EV are environment variables. They are GLOBAL variables which can be shared by all programs. In CGI mechanism, EVs are shared between the Web Server program and the CGI program so that the Web Server program can pass the INFO (it received from the FORM) to the CGI program.Try to create a simple CGI-based web page at your CS account6. Create a simple CGI-based web page at your CS accountCREATE a FORM and its CGI program for displaying back INFO entered in the FORM (EXAMPLE 1) ?SET-UP the a working folder for the FORM and CGI programs:Login to your CS account using Putty Go inside the WEB folder (cd WWW)Go inside your course folder (cd eb)Go inside your working folder (cd w)Create a folder called cgi(mkdir cgi-example1)Go inside that folder (cd cgi-example1)Use a text editor program (jpico, emacs, vi, joe, …) to CREATE FILES inside cgi:a file named “p1.htm” which contains a HTML code to display the FORM to the users (to input INFO), with the contents showed below.a file named “p1x.htm” which contains HTML output (to display RESULTS), with the contents showed below. This file is only temporary use and can be deleted later.a file named “p1py.cgi” which contains a CGI program which processes the INFO from the FORM (via EV) and produce the HTML output above, with the contents showed below.>mkdir cgi>chmod 755 cgi>cd cgi>jpico p1.htm>jpico p1x.htm>chmod 755 p1py.cgi018224500After “p1py.cgi” is built based on the HTML code in “p1x.htm” you can delete the “p1x.htm” file. So, you will need just two files in the db3-1 folder:file “p1.htm” which contains a HTML code to display the FORM to the users (to input INFO)file “p1py.cgi” which contains a CGI program which processes the INFO from the FORM (via EV) and produce the HTML output above.Set the permission for both files as 755 (chmod 755 *).To TEST if they work correctly: open a web browser and type the following address:cs.newpaltz.edu/~UserName/cgi-example1/p1.htm ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download