Skip to content
Snippets Groups Projects
Commit dddb5d13 authored by ale's avatar ale
Browse files

use a POST request for uploads to work around a gevent issue

parent b9a36274
No related branches found
No related tags found
No related merge requests found
......@@ -56,7 +56,7 @@ class Uploader(object):
headers={'X-Key': self.api_key,
'Content-Type': 'audio/mpeg',
'Content-Length': str(filesize)})
req.get_method = lambda: 'PUT'
req.get_method = lambda: 'POST'
result = json.loads(urllib2.urlopen(req).read())
return result['status']
finally:
......
......@@ -44,7 +44,7 @@ def _upload_mp3(incoming_fd, sha1):
log.info('successfully stored %s' % (sha1,))
@app.route('/upload/<sha1>', methods=['PUT'])
@app.route('/upload/<sha1>', methods=['POST'])
def upload(sha1):
if request.content_type != 'audio/mpeg':
log.error('attempted upload with wrong content-type (%s)' % (
......@@ -58,7 +58,10 @@ def run_receiver(port, storage_dir, db_url):
global storage_root
storage_root = storage_dir
init_db(db_url)
app.run(host='0.0.0.0', port=port, use_reloader=False)
from gevent.wsgi import WSGIServer
http_server = WSGIServer(('0.0.0.0', port), app)
http_server.serve_forever()
def main():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment