Skip to content
This repository
Browse code

Merge pull request #23 from CoolGoose/patch-4

Updated the tutorial...
  • Loading branch information...
commit 1038faee84ecb23a5b03b1d7e9dfc15b8733590c 2 parents 4bd1d81 + c14f4f1
Aaron Swartz authored April 15, 2012

Showing 1 changed file with 22 additions and 9 deletions. Show diff stats Hide diff stats

  1. 31  docs/0.3/tutorial.md
31  docs/0.3/tutorial.md
Source Rendered
@@ -44,12 +44,6 @@ The first part is a [regular expressions](http://osteele.com/tools/rework/) that
44 44
 
45 45
 This line says we want the URL `/` (i.e. the front page) to be handled by the class named `index`.
46 46
 
47  
-Now we need to create an application specifying the urls.
48  
-
49  
-    app = web.application(urls, globals())
50  
-
51  
-This tells web.py to create an application with the URLs we listed above, looking up the classes in the global namespace of this file.
52  
-
53 47
 <a name="getpost"> </a>
54 48
 ## GET and POST: the difference
55 49
 
@@ -65,14 +59,33 @@ In our web.py code, we make the distinction between the two clear:
65 59
 
66 60
 This `GET` function will now get called by web.py anytime someone makes a `GET` request for `/`.
67 61
 
68  
-Alright, now we just need to finish up with a final line telling web.py to start serving web pages:
  62
+Now we need to create an application specifying the urls and a way to tell  web.py to start serving web pages:
69 63
 
70  
-    if __name__ == "__main__": app.run()
  64
+    if __name__ == "__main__": 
  65
+        app = web.application(urls, globals())
  66
+        app.run()        
71 67
 
72  
-This tells web.py to serve the application we created above.
  68
+First we tell web.py to create an application with the URLs we listed above, looking up the classes in the global namespace of this file.
  69
+And finally we make sure that web.py serves the application we created above.
73 70
 
74 71
 Now notice that although I've been talking a lot here, we only really have five or so lines of code. That's all you need to make a complete web.py application.
75 72
 
  73
+For easier access, here's how your code should look like:
  74
+
  75
+    import web
  76
+    
  77
+    urls = (
  78
+        '/', 'index'
  79
+    )
  80
+    
  81
+    class index:
  82
+        def GET(self):
  83
+            return "Hello, world!"
  84
+    
  85
+    if __name__ == "__main__":
  86
+        app = web.application(urls, globals())
  87
+        app.run()
  88
+
76 89
 <a name="start"> </a>
77 90
 ## Start the server
78 91
 

0 notes on commit 1038fae

Please sign in to comment.
Something went wrong with that request. Please try again.