完善设置

This commit is contained in:
virusdefender 2016-05-03 13:54:09 +08:00
parent e05c5a284e
commit 1e3a185c1f
No known key found for this signature in database
GPG Key ID: 1686FB5677979E61
6 changed files with 6 additions and 24 deletions

View File

@ -1,7 +0,0 @@
FROM python:3.5
ENV PYTHONBUFFERED 1
RUN mkdir -p /code /code/log
COPY requirements.txt /tmp
RUN pip install -i http://pypi.douban.com/simple -r /tmp/requirements.txt --trusted-host pypi.douban.com
WORKDIR /code
CMD bash /code/dockerfiles/robot/run.sh

View File

@ -1,5 +0,0 @@
robot:
image: robot
environment:
- REDIS_PORT_6379_TCP_ADDR=
- REDIS_PASSWORD=

View File

@ -1,6 +0,0 @@
django
mysqlclient
celery
requests
djangorestframework
redis

View File

@ -1,2 +0,0 @@
#!/usr/bin/env bash
celery -A robot.tasks worker -l DEBUG

View File

@ -7,5 +7,5 @@ find /code -name "*.pyc" -delete
python -m compileall /code
chown -R nobody:nogroup /code/log
gunicorn openvj.wsgi:application -b 0.0.0.0:8080 --user nobody --group nogroup --reload &
celery -A openvj worker -l DEBUG -Q local &
celery -A openvj worker -l DEBUG -f /code/log/celery.log&
wait

View File

@ -13,6 +13,9 @@ from .tasks import get_problem, submit_dispatcher
from .utils import success_response, error_response, serializer_invalid_response, import_class
demo_key = "977c723a4f93ed311f052e6fad51728b"
class ProblemAPIView(APIView):
def get(self, request):
oj = request.GET.get("oj")
@ -20,7 +23,7 @@ class ProblemAPIView(APIView):
if not (oj and url):
return error_response("参数错误")
try:
api_key = request.META.get("HTTP_APIKEY", "d4f82f56514165f9f82bc6d434f02615")
api_key = APIKey.objects.get(api_key=request.META.get("HTTP_APIKEY", demo_key), is_valid=True)
except APIKey.DoesNotExist:
return error_response("需要api_key")
try:
@ -91,8 +94,7 @@ class SubmissionAPIView(APIView):
return error_response("oj不存在")
try:
api_key = request.META.get("HTTP_APIKEY", "d4f82f56514165f9f82bc6d434f02615")
api_key = APIKey.objects.get(api_key=api_key, is_valid=True)
api_key = APIKey.objects.get(api_key=request.META.get("HTTP_APIKEY", demo_key), is_valid=True)
except APIKey.DoesNotExist:
return error_response("需要api_key")