mirror of
https://github.com/Tygs/0bin.git
synced 2023-08-10 21:13:00 +03:00
Fixed data parsing bug
This commit is contained in:
parent
2264d79d02
commit
d1d455a41b
@ -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)
|
||||
|
19
start.py
19
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/<paste_id>')
|
||||
@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/<filename:re:.*>')
|
||||
@app.route('/static/<filename:path>')
|
||||
def server_static(filename):
|
||||
return static_file(filename, root=settings.STATIC_FILES_ROOT)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user