diff --git a/app.py b/app.py index 0658eac..35bbd00 100755 --- a/app.py +++ b/app.py @@ -13,7 +13,8 @@ from handlers import MainHandler, UploadHandler define("port", default=8888, help="run on the given port", type=int) -define("storage", default="/tmp/storage", help="dir", type=str) +define("storage", default="/tmp/storage", help="FIXME", type=str) +define("desc_min_len", default=15, help="FIXME", type=int) class Application(tornado.web.Application): diff --git a/handlers.py b/handlers.py index 283b3ec..7e1d669 100644 --- a/handlers.py +++ b/handlers.py @@ -37,10 +37,16 @@ def _count_hosted_files(self): return row class UploadHandler(BaseHandler): + _ERRORS = { 'EDESCTOOSHORT' : "Description is too small." } + def get(self): raise tornado.web.HTTPError(403) def post(self): + desc = tornado.escape.xhtml_escape(self.get_argument("description")) + if len(desc) < options.desc_min_len: + self.render("uploadfailure.html", reason=self._ERRORS['EDESCTOOSHORT']) + for f in self.request.files['payload']: local_fileid = self._get_sha1_sum(f['body']) db_fileid, filesize = self._check_file_existence(local_fileid) diff --git a/templates/uploadform.html b/templates/uploadform.html index 65d8da9..3b2f887 100644 --- a/templates/uploadform.html +++ b/templates/uploadform.html @@ -4,7 +4,11 @@

Hosted files: {{ hosted_files }}

{% end %}
+ + +
+