Permalink
Browse files

Added web.py test

  • Loading branch information...
1 parent 1ba4ac4 commit 5522915321ef72cb0068e9dbb24a3f701c6a8030 @afsec afsec committed Feb 20, 2012
View
@@ -0,0 +1 @@
+*.pyc
View
Binary file not shown.
View
@@ -0,0 +1,6 @@
+import web
+
+db = web.database(dbn='sqlite', db='hello.db')
+
+def get_rows():
+ return db.select('hello', order='id ASC')
View
@@ -0,0 +1,12 @@
+$def with (page)
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Hello World</title>
+</head>
+<body>
+
+ $:page
+
+</body>
+</html>
@@ -0,0 +1,7 @@
+$def with (rows)
+<p>Lorem ipsum dolor sit amet, consecteteur adipiscing elit nisi ultricies. Condimentum vel, at augue nibh sed. Diam praesent metus ut eros, sem penatibus. Pellentesque. Fusce odio posuere litora non integer habitant proin. Metus accumsan nibh facilisis nostra lobortis cum diam tellus. Malesuada nostra a volutpat pede primis congue nisl feugiat in fermentum. Orci in hymenaeos. Eni tempus mi mollis lacinia orci interdum lacus. Sollicitudin aliquet, etiam. Ac. Mi, nullam ligula, tristique penatibus nisi eros nisl pede pharetra congue, aptent nulla, rhoncus tellus morbi, ornare. Magna condimentum erat turpis. Fusce arcu ve suscipit nisi phasellus rutrum a dictumst leo, laoreet dui, ultricies platea. Porta venenatis fringilla vestibulum arcu etiam condimentum non.</p>
+
+<table border="1">
+ $for row in rows:
+ <tr><td>$row.id</td><td>$row.data</td></tr>
+</table>
@@ -0,0 +1 @@
+<p>Lorem ipsum dolor sit amet, consecteteur adipiscing elit nisi ultricies. Condimentum vel, at augue nibh sed. Diam praesent metus ut eros, sem penatibus. Pellentesque. Fusce odio posuere litora non integer habitant proin. Metus accumsan nibh facilisis nostra lobortis cum diam tellus. Malesuada nostra a volutpat pede primis congue nisl feugiat in fermentum. Orci in hymenaeos. Eni tempus mi mollis lacinia orci interdum lacus. Sollicitudin aliquet, etiam. Ac. Mi, nullam ligula, tristique penatibus nisi eros nisl pede pharetra congue, aptent nulla, rhoncus tellus morbi, ornare. Magna condimentum erat turpis. Fusce arcu ve suscipit nisi phasellus rutrum a dictumst leo, laoreet dui, ultricies platea. Porta venenatis fringilla vestibulum arcu etiam condimentum non.</p>
View
@@ -0,0 +1,31 @@
+import web
+import model
+
+urls = (
+ '/', 'Index',
+ '/hellos', 'Hellos',
+ '/hellodb', 'Hellodb',
+)
+
+render = web.template.render('templates', base='base')
+
+class Index:
+
+ def GET(self):
+ return 'Hello World!'
+
+class Hellos:
+
+ def GET(self):
+ return render.hellos()
+
+class Hellodb:
+
+ def GET(self):
+ rows = model.get_rows()
+ return render.hellodb(rows)
+
+app = web.application(urls, globals())
+
+if __name__ == '__main__':
+ app.run()

0 comments on commit 5522915

Please sign in to comment.