def up_delete(req, path): """docstring for up_get""" if req.is_xhr and req.method == 'DELETE': sid = Up.delete(path) return Response(simplejson.dumps({"ok": True, "sid": sid}), mimetype='application/json')
def up(req): if req.method == 'POST': username = req.authorization.username password = req.authorization.password user = User.db.get(username) if user and User.chkpwd(password, user['password']): for file in req.files: content_type = map_mime(req.files[file].filename.split('.')[-1]) resp = Up.create(username, req.files[file].read(), name=req.files[file].filename, content_type=content_type) url = 'http://kinaj.com/u/%s' % resp return Response(simplejson.dumps({"ok": True, "url": url}), mimetype='application/json') return Response(simplejson.dumps({"ok": False, "error": "omfg"}), mimetype='application/json')
def up_list(req): """docstring for up_list""" if req.method == 'GET': docs = [wrap(p) for p in Up.list(req.session['username'])] context = { "docs": docs } return render_html('u/list.html', context) else: raise NotFound
def up_get(req, path): """docstring for up_get""" if req.method == 'GET': attachment = Up.retrieve(path) return Response(attachment['file'], mimetype=attachment['content_type'])