Gentoo Archives: gentoo-commits

From: Vikraman Choudhury <vikraman.choudhury@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gentoostats:master commit in: server/, server/templates/
Date: Fri, 06 May 2011 14:42:24
Message-Id: 085560c594307487d3af47da41d39e724d0339fc.vikraman@gentoo
1 commit: 085560c594307487d3af47da41d39e724d0339fc
2 Author: Vikraman Choudhury <vikraman.choudhury <AT> gmail <DOT> com>
3 AuthorDate: Fri May 6 14:41:47 2011 +0000
4 Commit: Vikraman Choudhury <vikraman.choudhury <AT> gmail <DOT> com>
5 CommitDate: Fri May 6 14:41:47 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoostats.git;a=commit;h=085560c5
7
8 first commit for server code
9
10 ---
11 server/config.py | 4 ++++
12 server/main.py | 39 +++++++++++++++++++++++++++++++++++++++
13 server/templates/error_404.html | 6 ++++++
14 server/templates/error_500.html | 5 +++++
15 server/templates/index.html | 4 ++++
16 server/templates/layout.html | 12 ++++++++++++
17 6 files changed, 70 insertions(+), 0 deletions(-)
18
19 diff --git a/server/config.py b/server/config.py
20 new file mode 100644
21 index 0000000..5ef7087
22 --- /dev/null
23 +++ b/server/config.py
24 @@ -0,0 +1,4 @@
25 +import web
26 +
27 +render = web.template.render('templates/', base='layout')
28 +
29
30 diff --git a/server/main.py b/server/main.py
31 new file mode 100755
32 index 0000000..51ae445
33 --- /dev/null
34 +++ b/server/main.py
35 @@ -0,0 +1,39 @@
36 +#!/usr/bin/env python
37 +
38 +import web
39 +import config
40 +from config import render
41 +import json
42 +
43 +urls = (
44 + r'/', 'index',
45 + r'/(.+)', 'stats'
46 +)
47 +
48 +class index:
49 + def GET(self):
50 + return render.index()
51 +
52 +class stats:
53 + def GET(self, uuid):
54 + return '<html><body>GET success</body></html>'
55 +
56 + def POST(self, uuid):
57 + pdata = json.JSONDecoder().decode(web.data())
58 + print pdata
59 + return 'Post for ' + uuid + ' successful'
60 +
61 +def notfound():
62 + return web.notfound(render.error_404())
63 +
64 +def internalerror():
65 + return web.internalerror(render.error_500())
66 +
67 +app = web.application(urls, globals())
68 +
69 +app.notfound = notfound
70 +app.internalerror = internalerror
71 +
72 +if __name__ == "__main__":
73 + app.run()
74 +
75
76 diff --git a/server/templates/error_404.html b/server/templates/error_404.html
77 new file mode 100644
78 index 0000000..d310a86
79 --- /dev/null
80 +++ b/server/templates/error_404.html
81 @@ -0,0 +1,6 @@
82 +$var title: Page not found
83 +
84 +<p>The requested page was not found.</p>
85 +
86 +<p><strong>Developer note:</strong> Because Google and Microsoft think its OK to violate web standards for their own benefit, you must ensure that your error pages are larger than 512 bytes if you wish them to be displayed instead of the "friendly" error pages the browsers show. Which is why this message is here. To make the page longer. Bah.</p>
87 +
88
89 diff --git a/server/templates/error_500.html b/server/templates/error_500.html
90 new file mode 100644
91 index 0000000..2314e76
92 --- /dev/null
93 +++ b/server/templates/error_500.html
94 @@ -0,0 +1,5 @@
95 +$var title: Internal error
96 +
97 +<p>Oops, it seems something is broke on the server. Please try again.</p>
98 +
99 +<p><strong>Developer note:</strong> Because Google and Microsoft think its OK to violate web standards for their own benefit, you must ensure that your error pages are larger than 512 bytes if you wish them to be displayed instead of the "friendly" error pages the browsers show. Which is why this message is here. To make the page longer. Bah.</p>
100
101 diff --git a/server/templates/index.html b/server/templates/index.html
102 new file mode 100644
103 index 0000000..11fafb6
104 --- /dev/null
105 +++ b/server/templates/index.html
106 @@ -0,0 +1,4 @@
107 +$var title: Gentoostats
108 +
109 +Welcome to the gentoostats webapp
110 +
111
112 diff --git a/server/templates/layout.html b/server/templates/layout.html
113 new file mode 100644
114 index 0000000..48140d6
115 --- /dev/null
116 +++ b/server/templates/layout.html
117 @@ -0,0 +1,12 @@
118 +$def with (content)
119 +
120 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
121 +<html xmlns="http://www.w3.org/1999/xhtml">
122 +<head>
123 +<title>$content.title</title>
124 +</head>
125 +<body>
126 +$:content
127 +</body>
128 +</html>
129 +