Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Tài liệu đang bị lỗi
File tài liệu này hiện đang bị hỏng, chúng tôi đang cố gắng khắc phục.
Advance Praise for Head First Python Part 6 doc
Nội dung xem thử
Mô tả chi tiết
you are here 4 215
web development
You can put your program on the Web
You’ll want to be
able to share your
functionality with lots
of people...
...but you probably want
only one version of your
program “out there” that
everyone accesses...
...and you need to make sure
updates to your program
are easy to apply.
A “webapp” is what you want.
If you develop your program as a Web-based application (or webapp, for short),
your program is:
• Available to everyone who can get to your website
• In one place on your web server
• Easy to upate as new functionality is needed
But…how do webapps actually work?
216 Chapter 7
anatomy of a web request
Webapps Up Close
The Internet
I just type the
web address into my
browser’s location bar
Step 1: Your user enters and press Enter... a web address, selects
a hyperlink, or clicks a
button in her chosen
web browser.
No matter what you do on the Web, it’s all about requests and responses. A web request is sent
from a web browser to a web server as the result of some user interaction. On the web server, a
web response (or reply) is formulated and sent back to the web browser. The entire process can
be summarized in five steps.
Step 2: The web
browser converts
the user’s action
into a web request
and sends it to a
server over the
Internet.
Hey, hello there...what’s this?
A web request just for me? How
nice...
Step 3: The web server
receives the web request
and has to decide what
to do next.
Web
Server
Deciding what to do next
One of two things happen at this point. If the web request
is for static content—such as an HTML file, image, or
anything else stored on the web server’s hard disk—the web
server locates the resource and returns it to the web browser as
a web response.
If the request is for dynamic content—that is, content that
must be generated—the web server runs a program to produce
the web response.
Here comes a web
request.
you are here 4 217
web development
The Internet
That’s exactly what I
need. Thanks!
Step 4: The web server
processes the web
request, creating a web
response, which is sent
back over the Internet
to the waiting web
browser.
Web
Server
Step 5: The web
browser receives the
web response and
displays it on your
user’s screen.
The (potentially) many substeps of step 4
In practice, step 4 can involve multiple substeps, depending
on what the web server has to do to produce the response.
Obviously, if all the server has to do is locate static content
and sent it back to the browser, the substeps aren’t too
taxing, because it’s all just file I/O.
However, when dynamic content must be generated, the substeps involve the web server locating the program to execute,
executing the located program, and then capturing the output
from the program as the web response…which is then sent
back to the waiting web browser.
This dynamic content generation process has been
standardized since the early days of the Web and is known
as the Common Gateway Interface (CGI). Programs
that conform to the standard are often referred to as CGI
scripts.
Here comes a web
response.
Here you go...a web
response generated just for
you. Enjoy!
218 Chapter 7
webapp requirements
What does your webapp need to do?
Let’s take a moment to consider what you want your webapp to look like
and how it should behave on your user’s web browser. You can then use this
information to help you specify what your webapp needs to do.
I guess I need a nice,
friendly home page to
kick things off, eh?
Yeah...and I want to be
able to get at my times
easily...
...and once I’ve
selected mine, I want
them to look nice on
my screen, so I can print
them for my mom.
you are here 4 219
web development
There’s nothing like grabbing your pencil and a few blank paper
napkins to quickly sketch a simple web design. You probably
need three web pages: a “welcome” page, a “select an athlete”
page, and a “display times” page. Go ahead and draw out a rough
design on the napkins on this page, and don’t forget to draw any
linkages between the pages (where it makes sense).