LING 408/508: Computational Techniques for Linguists

Slides:



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

LING 408/508: Programming for Linguists Lecture 12 October 2 nd.
Adding Dynamic Content to your Web Site
Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
CS 898N – Advanced World Wide Web Technologies Lecture 6: PERL and CGI Chin-Chih Chang
Simple PHP application. A simple application We are going to develop a simple PHP application with a Web interface. The user enters two numbers and the.
LING 408/508: Programming for Linguists Lecture 16 October 16 th.
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.
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 Homework / Exam Exam 3 –Solutions Posted –Questions? HW8 due next class Final Exam –See posted schedule Websites on UNIX systems Course Evaluations.
Advance Database Management Systems Lab no. 5 PHP Web Pages.
CP3024 Lecture 3 Server Side Facilities. Lecture contents  Server side includes  Common gateway interface (CGI)  PHP Hypertext Preprocessor (PHP) pages.
LING 408/508: Programming for Linguists Lecture 17 October 21 st.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,
Internet / Intranet Fall 2000 Class 7. Brandeis University Internet/Intranet Spring Class 7 Agenda Project / Homework Discussion Forms Validating.
Internet / Intranet CIS-536 Class 7. 2 HTML Forms A Method to Allow Users to Pass Information to a CGI Script Forms Allow Information to Be Entered Via:
Python CGI programming
CSC 2720 Building Web Applications HTML Forms. Introduction  HTML forms are used to collect user input.  The collected input is typically sent to a.
LING 408/508: Programming for Linguists Lecture 4 September 2 nd.
PHP - Basic Language Constructs CSCI 297 Scripting Languages - Day Two.
Website Development with PHP and MySQL Saving Data.
Chapter 6 Server-side Programming: Java Servlets
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.
HTML Form Widgets. Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back.
LING 408/508: Programming for Linguists Lecture 17 October 28 th.
LING 408/508: Programming for Linguists Lecture 8 September 23 rd.
LING 408/508: Programming for Linguists Lecture 18 November 2 nd.
 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.
LING 408/508: Programming for Linguists
World Wide Web Components Browsers and Servers CGI Processing Model (Common Gateway Interface) © Norman White, 2001.
(see online resources, e.g. SY306 Web and Databases for Cyber Operations Slide Set #9: CGI with Python.
1) PHP – Personal Home Page Scripting Language 2) JavaScript.
CS 330 Class 8 Homework A pattern that contains a word with an optional period A pattern that contains Fred with a space (not Freddy) See regexp.txt guest4.htm.
University of Kansas Department of Electrical Engineering and Computer Science Dr. Susan Gauch April 21, 2005 I T T C Introduction to Web Technologies.
© 2004 D. J. Foreman T&F-1 CS205 Tables & Forms. T&F-2 ©2007 D. J. Foreman Tables.
The Common Gateway Interface (CGI) Pat Morin COMP2405.
PHP using MySQL Database for Web Development (part II)
PHP (Session 2) INFO 257 Supplement.
CS 330 Class 7 Comments on Exam Programming plan for today:
How to Write Web Forms By Mimi Opkins.
CGI I: Basics Web Programming.
Introduction to CGI and ajax
DBW - PHP DBW2017.
The Linux Operating System
PHP Introduction.
Simple PHP application
LING 408/508: Computational Techniques for Linguists
LING 408/508: Computational Techniques for Linguists
CGI Programming Part II UNIX Security
Introduction to CGI and ajax
LING 408/508: Computational Techniques for Linguists
LING 408/508: Computational Techniques for Linguists
LING 408/508: Computational Techniques for Linguists
LING 408/508: Computational Techniques for Linguists
LING 408/508: Computational Techniques for Linguists
LING 408/508: Computational Techniques for Linguists

World Wide Web Components
An Example of a TCP/IP Application: the World Wide Web
CS205 Tables & Forms © 2012 D. J. Foreman.
Shellshock a.k.a. Bashdoor / Bash bug
CS205 Tables & Forms © 2008 D. J. Foreman.
CGI I: Basics Web Programming.
CS205 Tables & Forms © 2004 D. J. Foreman.
PHP By Prof. B.A.Khivsara Note: The material to prepare this presentation has been taken from internet and are generated only for students reference and.
MSc Internet Computing
Web Application Development Using PHP
SHELLSHOCK ATTACK.
Presentation transcript:

LING 408/508: Computational Techniques for Linguists Lecture 21

Administrivia Both Homework 7 and 8 have been graded Homework 9 today

Example: example.cgi SiteSites$ ./example.cgi Content-Type: text/html; charset=utf-8 <html><head></head> <body><h1>~sandiway/Sites/example.cgi</h1> <p>Now: Tue Oct 30 20:37:01 MST 2018 </p> <p>User: sandiway <script src="canvasjs.min.js"></script> <div id="cc" style="height: 400px; max-width: 600px; margin: 0px auto;"></div> <script> window.onload = function() { var chart = new CanvasJS.Chart("cc", { animationEnabled: true, title: { text: "Disk Space: 1908108MB" }, data: [{ type: "pie", startAngle: 240, yValueFormatString: "##0.00'%'", indexLabel: "{label} {y}", dataPoints: [ {y: 626807/1908108*100, label: "Used", color: "Bisque"}, {y: 1279477/1908108*100, label: "Unused", color: "Tan"} ]}]} ); chart.render(); } </script></body></html>

Example: example.cgi $2 $3 $4

Example: example.cgi Used the free(?) canvasjs.min.js library from www.canvasjs.com They have source code for many examples of javascript charts. Wondering what happens after 30 days…

Today's Topics Sending form data to the webserver using: GET method POST method There are also (many) other methods to communicate information depending on the kind of webserver we run: e.g. Apache Tomcat (for Java) e.g. WebSocket interface (for bidirectional data passing) etc.

Sending information using GET HTML form: <form action="http://localhost/cgi-bin/get.cgi" method="GET"> First: <input type="text" name="first" size=12> Last: <input type="text" name="last" size=12> <input type="submit"> </form> Information encoded using alphanumeric characters: why? URLs are restricted to alphanumeric characters only bash accesses the URL-encoded string via the environment variable QUERY_STRING http://localhost/cgi-bin/get.cgi?first=Sandiway&last=Fong

Sending information using GET get.cgi: #!/bin/bash echo "Content-Type: text/plain" echo #echo $QUERY_STRING origIFS=$IFS IFS='=&' set -- $QUERY_STRING IFS=$origIFS echo "1:<$1> 2:<$2> 3:<$3> 4:<$4>" = and & http://localhost/cgi-bin/get.cgi?first=Sandiway&last=Fong In bash: IFS = internal field separator (for arguments) default: space newline tab set -- String -- option: positional parameters $1,$2,..etc. are set after splitting String

Sending information using GET get.cgi: #!/bin/bash echo "Content-Type: text/plain" echo #echo $QUERY_STRING origIFS=$IFS IFS='=&' set -- $QUERY_STRING IFS=$origIFS echo "1:<$1> 2:<$2> 3:<$3> 4:<$4>"

Sending information using GET OS X /Library/WebServer/CGI-Executables/ $ls -l get.cgi -rwxr-xr-x 1 root wheel 161 Oct 16 2014 get.cgi sudo chmod 755 get.cgi Ubuntu /usr/lib/cgi-bin/

Sending information using POST

Sending information using POST HTML form: <form action="http://localhost/cgi-bin/read.cgi" method="POST"> First: <input type="text" name="first" size=12> Last: <input type="text" name="last" size=12> <input type="submit"> </form> bash accesses the URL-encoded string on standard input via read cf. GET using QUERY_STRING

Sending information using POST bash accesses the URL-encoded string on standard input via read read.cgi: #!/bin/bash echo "Content-Type: text/plain" echo read input origIFS=$IFS IFS='=&' set -- $input IFS=$origIFS echo "<$2><$4>"

Sending information using POST Client-side code: Server-side code: read.cgi: #!/bin/bash echo "Content-Type: text/plain" echo read input origIFS=$IFS IFS='=&' set -- $input IFS=$origIFS echo "<$2><$4>"

Limitations of positional parameters set values: origIFS=$IFS IFS='=&' set -- $QUERY_STRING IFS=$origIFS echo "1:<$1> 2:<$2> 3:<$3> 4:<$4>"

Files and Locations Server cgi-bin directory: Webserver logs: MacOS: /Library/WebServer/CGI-Executables Ubuntu: /usr/lib/cgi-bin Webserver logs: MacOS: /var/log/apache2/error_log Ubuntu: /var/log/apache2/error.log Course webpage: form-get.html form-post.html get.cgi (needs 755 permissions) read.cgi (needs 755 permissions)

Error Log Example: error log: … [Wed Oct 31 22:08:01.555932 2018] [cgi:error] [pid 4600] [client ::1:51340] AH01215: (13)Permission denied: exec of '/Users/sandiway/Sites/get2.cgi' failed: /Users/sandiway/Sites/get2.cgi [Wed Oct 31 22:08:01.556059 2018] [cgi:error] [pid 4600] [client ::1:51340] End of script output before headers: get2.cgi

Homework 9 Use the cgi-bin methods to implement a BMI bash shell script on the webserver. i.e. you should modify your BMI program to accept data from a html form and compute the value on the server side Use both GET and POST methods to communicate the weight, height and units. Submit your .html and .cgi files Submit screenshots to show it working in both cases Due next Monday by midnight

Example: adding names to a server list Normally, you'd set up database software,e.g. mysql, on the webserver

Example: adding names to a server list Server-side code: get2.cgi Client-side code: addnames.html Data file: touch names-list.txt chmod a+w names-list.txt