CMPT165_26_OnlineCatalog

CMPT165_26_OnlineCatalog - Example: an online catalog...

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

View Full Document Right Arrow Icon
–1 Example: an online catalog Wherein we share our darkest secrets with the entire world © Colin Stewart, 2009 Online catalog Online catalog • in this lecture, we'll be making an online movie catalog • the catalog will allow us to add information about movies into a catalog • it will also allow us to search for movies that are in the catalog • the movie information will all be stored in a file called movieCatalog.data
Background image of page 1

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

View Full DocumentRight Arrow Icon
–2 No static HTML No static HTML • unlike previous dynamic websites we've made so far, this site will have no static HTML • that is, we will not be making any HTML ( .html ) files h all the HTML code for our pages will be dynamic – i.e. generated with Python • this will become clearer with some examples Online catalog Online catalog • here's the catalog home page: • the home page has links to two different pages – one for searching the catalog, one for adding movies to it
Background image of page 2
–3 Online catalog Online catalog • if we click on the first link ("Search for a movie"), we'll arrive at this page: • from here, we can type in the name of a movie to search for b Online catalog Online catalog • for example, if we search for "The Dark Knight" … b • … we can see some information about the movie (title, year, genre) h this assumes that this information has already been added to the catalog
Background image of page 3

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

View Full DocumentRight Arrow Icon
–4 Online catalog Online catalog • however, if we search for a movie that is not in the catalog … b • … then we're told it can't be found Online catalog Online catalog • if we click on the second link on the home page ("Add a movie"), we'll arrive at this page: b • from here, we can type in information for a new movie to add to the catalog
Background image of page 4
–5 Online catalog Online catalog • for example … b • from here, clicking "Add to catalog" will save the movie information to movieCatalog.data • clicking "Cancel" will return you to the home page Online catalog Online catalog • in action (if "Add to Catalog" is clicked): b • now, we would be able to find the movie "Brazil" through the search page
Background image of page 5

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

View Full DocumentRight Arrow Icon
–6 The home page The home page • let's start coding this thing • here's the home page again • we'll generate this page with a script called movieHome.py The home page The home page • here's movieHome.py : print 'Content-type: text/html' print print '<html>' print '<head>' print '<title></title>' print '</head>' print '<body>' print '<h1>Movie catalog</h1>' print '<div><a href=" movieSearchForm.py ">' + \ 'Search for a movie</a></div>' print '<div><a href=" movieAddForm.py ">' + \ 'Add a movie</a></div>' print '</body>' print '</html>'
Background image of page 6
–7 The home page The home page • note that we didn't arrive at this script from a form (we can just type its URL directly into the address bar in Firefox and it would work) ( http://cmpt165.cs.sfu.ca/~cjs/examples/ movieHome.py ) • you can only do this with scripts that don't get any data from a form (i.e. scripts that do not use form[ "…" ].value or form.has_key( "…" ) ) • but why would you do something like this?
Background image of page 7

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

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

This note was uploaded on 07/30/2009 for the course CMPT 165 taught by Professor Ramesh during the Summer '09 term at Simon Fraser.

Page1 / 25

CMPT165_26_OnlineCatalog - Example: an online catalog...

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

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