diff options
| author | Martin Vilcans <martin@librador.com> | 2011-08-23 00:26:05 +0200 |
|---|---|---|
| committer | Martin Vilcans <martin@librador.com> | 2011-08-23 00:26:05 +0200 |
| commit | 95f1fab08d079f2ed63499ef5b41a55c17c2d84e (patch) | |
| tree | 03c2292628efc7474333379df56fc99b9ad79ab9 /server/main.py | |
| parent | 760e0929449808db8fec420798e0d031b168f79d (diff) | |
First simplistic version of the AppEngine server
Diffstat (limited to 'server/main.py')
| -rw-r--r-- | server/main.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/server/main.py b/server/main.py new file mode 100644 index 0000000..6e87e18 --- /dev/null +++ b/server/main.py @@ -0,0 +1,33 @@ + +# See http://blog.rutwick.com/use-bottle-python-framework-with-google-app-engine + +from StringIO import StringIO + +import bottle +from bottle import route, template, request, response, error, debug +from google.appengine.ext.webapp.util import run_wsgi_app + +from screenplain.export.text import to_text + +@route('/text', method='POST') +def DisplayForm(): + response.content_type = 'text/plain; charset=utf-8' + input = StringIO(request.forms.get('data')) + output = StringIO() + to_text(input, output) + return output.getvalue() + +def main(): + debug(True) + run_wsgi_app(bottle.default_app()) + +@error(403) +def Error403(code): + return 'Forbidden!' + +@error(404) +def Error404(code): + return 'Not found' + +if __name__=="__main__": + main() |
