diff --git a/dockerfiles/robot/Dockerfile b/dockerfiles/robot/Dockerfile deleted file mode 100644 index bf9733e..0000000 --- a/dockerfiles/robot/Dockerfile +++ /dev/null @@ -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 \ No newline at end of file diff --git a/dockerfiles/robot/docker-compose.remote-example.yml b/dockerfiles/robot/docker-compose.remote-example.yml deleted file mode 100644 index a186861..0000000 --- a/dockerfiles/robot/docker-compose.remote-example.yml +++ /dev/null @@ -1,5 +0,0 @@ -robot: - image: robot - environment: - - REDIS_PORT_6379_TCP_ADDR= - - REDIS_PASSWORD= diff --git a/dockerfiles/robot/requirements.txt b/dockerfiles/robot/requirements.txt deleted file mode 100644 index 4f6f551..0000000 --- a/dockerfiles/robot/requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -django -mysqlclient -celery -requests -djangorestframework -redis \ No newline at end of file diff --git a/dockerfiles/robot/run.sh b/dockerfiles/robot/run.sh deleted file mode 100644 index 45b2613..0000000 --- a/dockerfiles/robot/run.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -celery -A robot.tasks worker -l DEBUG \ No newline at end of file diff --git a/dockerfiles/server/run.sh b/dockerfiles/server/run.sh index bf26bbe..1b7a22c 100644 --- a/dockerfiles/server/run.sh +++ b/dockerfiles/server/run.sh @@ -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 \ No newline at end of file diff --git a/server/views.py b/server/views.py index 6d26779..99dbcc5 100644 --- a/server/views.py +++ b/server/views.py @@ -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")