Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed the code formatting I think

  • Loading branch information...
commit 7e527a458a68f0db2cfd78c68a3ba562f7c13945 1 parent 8e21f69
@dublo7 dublo7 authored anandology committed
Showing with 40 additions and 38 deletions.
  1. +40 −38 cookbook/streaming_large_files.md
View
78 cookbook/streaming_large_files.md
@@ -10,43 +10,45 @@ This is an example of how you can use web.py to stream large files. You'll find
You need the content type and chunked header to make things show up correctly on a typical web browser.
Simple Example
-import web
-import time
-
-urls = (
- "/", "count_holder",
- "/(.*)", "count_down",
- )
-app = web.application(urls, globals())
-
-class count_down:
- def GET(self,count):
- web.header('Content-type','text/html')
- web.header('Transfer-Encoding','chunked')
- yield '<h2>Prepare for Launch!</h2>'
- j = '<li>Liftoff in %s...</li>'
- yield '<ul>'
- count = int(count)
- for i in range(count,0,-1):
- out = j % i
+ # Simple streaming server demonstration
+ import web
+ import time
+
+ urls = (
+ "/", "count_holder",
+ "/(.*)", "count_down",
+ )
+ app = web.application(urls, globals())
+
+
+ class count_down:
+ def GET(self,count):
+ web.header('Content-type','text/html')
+ web.header('Transfer-Encoding','chunked')
+ yield '<h2>Prepare for Launch!</h2>'
+ j = '<li>Liftoff in %s...</li>'
+ yield '<ul>'
+ count = int(count)
+ for i in range(count,0,-1):
+ out = j % i
+ time.sleep(1)
+ yield out
+ yield '</ul>'
time.sleep(1)
- yield out
- yield '</ul>'
- time.sleep(1)
- yield '<h1>Lift off</h1>'
-
-class count_holder:
- def GET(self):
- web.header('Content-type','text/html')
- web.header('Transfer-Encoding','chunked')
- boxes = 4
- delay = 3
- countdown = 10
- for i in range(boxes):
- output = '<iframe src="/%d" width="200" height="500"></iframe>' % (countdown - i)
- yield output
- time.sleep(delay)
-
-if __name__ == "__main__":
- app.run()
+ yield '<h1>Lift off</h1>'
+
+ class count_holder:
+ def GET(self):
+ web.header('Content-type','text/html')
+ web.header('Transfer-Encoding','chunked')
+ boxes = 4
+ delay = 3
+ countdown = 10
+ for i in range(boxes):
+ output = '<iframe src="/%d" width="200" height="500"></iframe>' % (countdown - i)
+ yield output
+ time.sleep(delay)
+
+ if __name__ == "__main__":
+ app.run()
Please sign in to comment.
Something went wrong with that request. Please try again.