Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djrandom-py-deleted-112
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This project is pending deletion, and will be deleted on
2025-06-14
. Repository and other project resources are read-only.
Show more breadcrumbs
ale
djrandom-py-deleted-112
Commits
dddb5d13
Commit
dddb5d13
authored
13 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
use a POST request for uploads to work around a gevent issue
parent
b9a36274
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
client/djrandom_client/upload.py
+1
-1
1 addition, 1 deletion
client/djrandom_client/upload.py
server/djrandom/receiver/receiver.py
+5
-2
5 additions, 2 deletions
server/djrandom/receiver/receiver.py
with
6 additions
and
3 deletions
client/djrandom_client/upload.py
+
1
−
1
View file @
dddb5d13
...
@@ -56,7 +56,7 @@ class Uploader(object):
...
@@ -56,7 +56,7 @@ class Uploader(object):
headers
=
{
'
X-Key
'
:
self
.
api_key
,
headers
=
{
'
X-Key
'
:
self
.
api_key
,
'
Content-Type
'
:
'
audio/mpeg
'
,
'
Content-Type
'
:
'
audio/mpeg
'
,
'
Content-Length
'
:
str
(
filesize
)})
'
Content-Length
'
:
str
(
filesize
)})
req
.
get_method
=
lambda
:
'
P
U
T
'
req
.
get_method
=
lambda
:
'
P
OS
T
'
result
=
json
.
loads
(
urllib2
.
urlopen
(
req
).
read
())
result
=
json
.
loads
(
urllib2
.
urlopen
(
req
).
read
())
return
result
[
'
status
'
]
return
result
[
'
status
'
]
finally
:
finally
:
...
...
This diff is collapsed.
Click to expand it.
server/djrandom/receiver/receiver.py
+
5
−
2
View file @
dddb5d13
...
@@ -44,7 +44,7 @@ def _upload_mp3(incoming_fd, sha1):
...
@@ -44,7 +44,7 @@ def _upload_mp3(incoming_fd, sha1):
log
.
info
(
'
successfully stored %s
'
%
(
sha1
,))
log
.
info
(
'
successfully stored %s
'
%
(
sha1
,))
@app.route
(
'
/upload/<sha1>
'
,
methods
=
[
'
P
U
T
'
])
@app.route
(
'
/upload/<sha1>
'
,
methods
=
[
'
P
OS
T
'
])
def
upload
(
sha1
):
def
upload
(
sha1
):
if
request
.
content_type
!=
'
audio/mpeg
'
:
if
request
.
content_type
!=
'
audio/mpeg
'
:
log
.
error
(
'
attempted upload with wrong content-type (%s)
'
%
(
log
.
error
(
'
attempted upload with wrong content-type (%s)
'
%
(
...
@@ -58,7 +58,10 @@ def run_receiver(port, storage_dir, db_url):
...
@@ -58,7 +58,10 @@ def run_receiver(port, storage_dir, db_url):
global
storage_root
global
storage_root
storage_root
=
storage_dir
storage_root
=
storage_dir
init_db
(
db_url
)
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
():
def
main
():
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment