Lecture 2.1 (Tuesday, Jan. 27)

Logistics

  • A0 in!
  • A1 is now out - the Shakespeare Browser

Note

We spent most of our time on Python data structures, the last part of these notes. We'll visit the HTML and URL material on Thursday.

Python and Flask and HTML

We're going to talk more about HTML.

Review the basic page:

<!doctype html>
<html>
<head>
<title>Hello, world</title>
</head>
<body>
<h1>Hello</h1>
<p>The world is greeted.</p>
</body>
</html>

There are ways that we want to structure the document.

h1, h2, …
These are heading tags. There are 6 of them for different levels of headings.
p
This is a paragraph. Does what it says on the tin. Usually has some space around it.
div
This is a generic block-level element - use this when you need a block, but there isn't something more meaningful to use.
ul and ol
Lists (unordered and ordered).

HTML is divided into block elements, like those above, and inline elements:

a
anchor, used to make links
em
emphasis (generally italics)
strong
strong emphasis (generally bold)
code
describe a piece of code (usually set in typewriter font)
span
a generic inline element

Let's review URLs:

http://example.com/foo/bar#wombat

The URL points to a page.

URL stands for Uniform Resource Locator. A URL is a form of URI, or Uniform Resource Identifier. There are a few other kinds of URIs, but we won't see them much.

You can see the URL in your browser address bar.

We can hyperlink to URLs.

URLs are mapped to functions in Flask, to files in web servers.

  • Show this off with my web site
  • Show off some pages doing things

Python and data structures

Hint

In class we did a number of Python examples. Consult the notebook with comments for that.

So far we've seen some basic Python code.

review Flask app from last week

Data in Python takes several forms:

  • Strings
  • Numbers
  • Booleans
  • None
  • Lists — they're like arrays, but you can change their size. We use these a lot.
  • Dictionaries — hash tables, they let us store things by key
  • Other object types

Everything in Python is an object, but that doesn't matter too much to us right now.

Examples:

a_string = 'foo'
a_number = 3
a_bool = False
a_list = ['foo', 'apple', 7]
a_dict = {'name': 'hackem muche', 'type': 'identify'}

Show off data structure actions in IPython Notebook.

Then move to Jinja if we have time