Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

New lines, decorator description. #3

Closed
wants to merge 1 commit into from

1 participant

@Ivoz
Owner

No description provided.

@Ivoz Ivoz closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 21, 2013
  1. @Ivoz

    New lines, decorator description.

    Ivoz authored
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 6 deletions.
  1. +12 −6 core/hello-world.md
View
18 core/hello-world.md
@@ -5,22 +5,27 @@ title: Hello World
---
-Now that we have Python and Flask installed it's time to start with our first website. But first we need to know a little about how the web browser retrieves data from a web server.
+Now that we have Python and Flask installed it's time to start with our first website.
+But first we need to know a little about how the web browser retrieves data from a web server.
# HTTP
-The HyperText Transfer Protocol is the network communication between your web browser and the server. In HTTP, the browser makes a _request_ and the server sends back a _response_.
+The HyperText Transfer Protocol is the network communication between your web browser and the server.
+In HTTP, the browser makes a _request_ and the server sends back a _response_.
There are two main types of request, `GET` and `POST`.
* The browser sends a `GET` request to retrieve data. For example, going to `http://www.opentechschool.org/team.html` will cause the browser to send `GET /team.html` to the server.
* The `POST` request is used to send data. For example if you fill out a web form and click `Submit` it will send the form data back to the server.
-We will be doing both GET and POST requests today. You've already handled a GET request with the Hello World example. Later on we will try POST.
+We will be doing both GET and POST requests today. You've already handled a GET request with the Hello World example.
+Later on we will try POST.
# Hello World - A Static Website
-In the early days people would write HTML files in a directory being watched by an Apache server. It was simple, but limiting. The content was _static_, with no way to make it change without editing the files on the server. Today we are going to start with something just as simple. This is the [Quickstart example](http://flask.pocoo.org/docs/quickstart/) from the Flask documentation.
+In the early days people would write HTML files in a directory being watched by an Apache web server.
+It was simple, but limiting. The content was _static_, with no way to make it change without editing the files on the server.
+Today we are going to start with something just as simple. This is the [Quickstart example](http://flask.pocoo.org/docs/quickstart/) from the Flask documentation.
Open a new file called `hello.py` in your workshop directory. This might look a little cryptic:
@@ -46,7 +51,8 @@ This imports the Flask library and creates a new website in a variable called `a
def hello_world():
return 'Hello World!'
-The `@` is new, it's called a _decorator_ and it used to give meaning to function definitions. In this case it says that the website should _route_ requests from the browser for `/` to this function.
+The `@` is new, it's called a _decorator_ and it used to cleverly modify the function below it.
+Flask lets you use its `app.route` decorator to let it know that this function should respond when you ask for the page at `/` (the home page).
The function itself returns the string "Hello World!". This will be sent to the web browser.
@@ -64,4 +70,4 @@ Open it in your browser! It probably looks something like this:
![](images/hello-world.png)
-Hmmm, looks a little basic. In the next section we will look at making it a little better looking.
+Hmmm, looks a little basic. In the next section we will look at making it a little better looking.
Something went wrong with that request. Please try again.