diff --git a/src/paste.py b/src/paste.py index 4c765e5..e7aa017 100644 --- a/src/paste.py +++ b/src/paste.py @@ -87,7 +87,8 @@ class Paste(object): comments = paste.read()[:-1] # remove the last coma if expiration != u'burn_after_reading': - expiration = datetime.strptime(expiration, '%Y-%m-%d %H:%M:%S.%f') + expiration = datetime.strptime(expiration.strip(), + '%Y-%m-%d %H:%M:%S.%f') except StopIteration: raise TypeError(u'File %s is malformed' % path) diff --git a/start.py b/start.py index 617b010..4d835a3 100644 --- a/start.py +++ b/start.py @@ -4,7 +4,8 @@ import os import hashlib import sys -from bottle import (Bottle, route, run, static_file, debug, view, request) +from bottle import (Bottle, route, run, abort, + static_file, debug, view, request) import settings @@ -40,25 +41,19 @@ def create_paste(): return '' -@app.route('/paste/') +@app.route('/paste/:paste_id') +@view('paste') def display_paste(paste_id): try: paste = Paste.load(paste_id) except (TypeError, ValueError): - return '' + abort(404, u"This paste does't exist or has expired") - if content: - expiration = request.forms.get('expiration', u'burn_after_reading') - paste = Paste(expiration=expiration, content=content) - paste.save() - - return paste.uuid - - return '' + return {'paste': paste} -@app.route('/static/') +@app.route('/static/') def server_static(filename): return static_file(filename, root=settings.STATIC_FILES_ROOT)