diff options
author | Vikraman Choudhury <vikraman.choudhury@gmail.com> | 2011-05-06 20:11:47 +0530 |
---|---|---|
committer | Vikraman Choudhury <vikraman.choudhury@gmail.com> | 2011-05-06 20:11:47 +0530 |
commit | 085560c594307487d3af47da41d39e724d0339fc (patch) | |
tree | fd804db4d6380b29f1177c4aa2ad183d3ec59718 | |
parent | housekeeping -- updated TODO (diff) | |
download | gentoostats-085560c594307487d3af47da41d39e724d0339fc.tar.gz gentoostats-085560c594307487d3af47da41d39e724d0339fc.tar.bz2 gentoostats-085560c594307487d3af47da41d39e724d0339fc.zip |
first commit for server code
-rw-r--r-- | server/config.py | 4 | ||||
-rwxr-xr-x | server/main.py | 39 | ||||
-rw-r--r-- | server/templates/error_404.html | 6 | ||||
-rw-r--r-- | server/templates/error_500.html | 5 | ||||
-rw-r--r-- | server/templates/index.html | 4 | ||||
-rw-r--r-- | server/templates/layout.html | 12 |
6 files changed, 70 insertions, 0 deletions
diff --git a/server/config.py b/server/config.py new file mode 100644 index 0000000..5ef7087 --- /dev/null +++ b/server/config.py @@ -0,0 +1,4 @@ +import web + +render = web.template.render('templates/', base='layout') + diff --git a/server/main.py b/server/main.py new file mode 100755 index 0000000..51ae445 --- /dev/null +++ b/server/main.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python + +import web +import config +from config import render +import json + +urls = ( + r'/', 'index', + r'/(.+)', 'stats' +) + +class index: + def GET(self): + return render.index() + +class stats: + def GET(self, uuid): + return '<html><body>GET success</body></html>' + + def POST(self, uuid): + pdata = json.JSONDecoder().decode(web.data()) + print pdata + return 'Post for ' + uuid + ' successful' + +def notfound(): + return web.notfound(render.error_404()) + +def internalerror(): + return web.internalerror(render.error_500()) + +app = web.application(urls, globals()) + +app.notfound = notfound +app.internalerror = internalerror + +if __name__ == "__main__": + app.run() + diff --git a/server/templates/error_404.html b/server/templates/error_404.html new file mode 100644 index 0000000..d310a86 --- /dev/null +++ b/server/templates/error_404.html @@ -0,0 +1,6 @@ +$var title: Page not found + +<p>The requested page was not found.</p> + +<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> + diff --git a/server/templates/error_500.html b/server/templates/error_500.html new file mode 100644 index 0000000..2314e76 --- /dev/null +++ b/server/templates/error_500.html @@ -0,0 +1,5 @@ +$var title: Internal error + +<p>Oops, it seems something is broke on the server. Please try again.</p> + +<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> diff --git a/server/templates/index.html b/server/templates/index.html new file mode 100644 index 0000000..11fafb6 --- /dev/null +++ b/server/templates/index.html @@ -0,0 +1,4 @@ +$var title: Gentoostats + +Welcome to the gentoostats webapp + diff --git a/server/templates/layout.html b/server/templates/layout.html new file mode 100644 index 0000000..48140d6 --- /dev/null +++ b/server/templates/layout.html @@ -0,0 +1,12 @@ +$def with (content) + +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>$content.title</title> +</head> +<body> +$:content +</body> +</html> + |