Perl语言入门和提高14

Perl语言入门和提高14

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Spring, 2008 1 Perl 语言高级编程专题 Lesson 14 周晓方 courses@xfzhou.homeftp.org Spring, 2008 2 Web browser & Http Server 1. User opens browser and enters a target address 2. Browser connects to the server (on port 80), and sends request 3. Server finds the web page and returns it with HTTP header. 4. If not found, server returns an error message. 5. Browser transforms the reply and display to user. Client Server GET /index.htm HTTP /1.0 HTTP /1.0 200 OK …… HTTP /1.0 404 Not Found • Try these: telnet www.fudan.edu.cn 80 type "GET / HTTP /1.0", with 2 ENTER's telnet mail.fudan.edu.cn 25 telnet mail.fudan.edu.cn 110 Spring, 2008 3 Web Server & CGI Perl 1 . User opens browser and enters a target address 2 . Browser connects to the server (on port 80), and sends request 3 . Server setups CGI environment and starts the Perl CGI script. After script terminals, server collects and returns the result. 4 . If Perl CGI script not found, server returns an error message. 5 . Browser transforms the reply and display to user. + The web page is dynamic, not static + Perl/CGI is almost platform independent (v.s. ASP etc) + Client browser is simple (v.s. client side scripts)- Speed may be slower if server is slow (v.s. ASP). Client Server GET HTTP … C G I Perl CGI script Spring, 2008 4 Install a local Web Server • Check if tcp/ip protocol is installed on your PC • 'xitami' free web server (www.xitami.com ) – xitami/Pro 是带 SSL 的 xitami http://www.xitami.com/download.htm • Install the GUI version of web server • Setu p http://localhost/admin • home of webpage: … /xitami/webpages • home of cgi scripts: … /xitami/cgi-bin • home of ftp root: … /xitami/ftproot/???/ • test server: http://localhost/ • test cgi: http://localhost/cgi-bin/testcgi Spring, 2008 5 Write a 1st Web Page • Add following lines to … /webpages/home.htm • Open IE & links to http://localhost/home.htm <html> <head> <title>My 1st Web Page</title> </head> <body> <h2>Hay! Welcome to my homepage!</h2> <hr> Still under <font color=red>construction</font>. <br><a href="/cgi-bin/time.pl">Time</a> </body> </html> Hay! Welcome to my homepage! Still under construction. Time Spring, 2008 6 Write a 1st CGI-Perl script • Add these lines to … /cgi-bin/time.pl • Click the "Time" link, and runs the script on server. #!/usr/bin/perl -w use strict; my $time = localtime(); print << "HERE"; Content-type: text/html <html><head><title>What's the time?</title> </head><body><h3>Current time is</h3> <hr width=50\% align=left> $time <br><br> <a href="/home.htm">Back</a> </body></html> HERE 1; Current time is Sun Nov 9 08:17:07 2003 Back Spring, 2008 7 Xitami Server Hints • 公网网站一定要拿 ICP 号 http://www.miibeian.gov.cn/ • 尽量避免开设论坛、博客、新闻等内容 • 解包 xiopen_2_5.zip 后可直接运行 – GUI / Console / Server / Control panel 版本 • 设置文件 – 需要简单认证的网页口令和密码: xitami.aut – 网站和虚拟网站的设置:...
View Full Document

Page1 / 3

Perl语言入门和提高14

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online