mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-12-28 16:12:13 +00:00
尝试使用Nginx X-Accel
This commit is contained in:
parent
e21f0c7301
commit
b550da5796
@ -9,6 +9,11 @@ location /api {
|
||||
client_max_body_size 200M;
|
||||
}
|
||||
|
||||
location /data/ {
|
||||
internal;
|
||||
alias /data/; # note that trailing slash
|
||||
}
|
||||
|
||||
location /admin {
|
||||
root /app/dist/admin;
|
||||
try_files $uri $uri/ /index.html =404;
|
||||
@ -17,4 +22,4 @@ location /admin {
|
||||
location / {
|
||||
root /app/dist;
|
||||
try_files $uri $uri/ /index.html =404;
|
||||
}
|
||||
}
|
||||
|
@ -95,12 +95,14 @@ _cpp_lang_spj_config = {
|
||||
}
|
||||
|
||||
_java_lang_config = {
|
||||
"template": """/*--PREPEND START--*/
|
||||
/*--PREPEND END--*/
|
||||
/*--TEMPLATE BEGIN--*/
|
||||
/*--TEMPLATE END--*/
|
||||
/*--APPEND START--*/
|
||||
/*--APPEND END--*/""",
|
||||
"template": """//PREPEND BEGIN
|
||||
//PREPEND END
|
||||
|
||||
//TEMPLATE BEGIN
|
||||
//TEMPLATE END
|
||||
|
||||
//APPEND BEGIN
|
||||
//APPEND END""",
|
||||
"compile": {
|
||||
"src_name": "Main.java",
|
||||
"exe_name": "Main",
|
||||
@ -119,12 +121,14 @@ _java_lang_config = {
|
||||
|
||||
|
||||
_py2_lang_config = {
|
||||
"template": """/*--PREPEND START--*/
|
||||
/*--PREPEND END--*/
|
||||
/*--TEMPLATE BEGIN--*/
|
||||
/*--TEMPLATE END--*/
|
||||
/*--APPEND START--*/
|
||||
/*--APPEND END--*/""",
|
||||
"template": """//PREPEND BEGIN
|
||||
//PREPEND END
|
||||
|
||||
//TEMPLATE BEGIN
|
||||
//TEMPLATE END
|
||||
|
||||
//APPEND BEGIN
|
||||
//APPEND END""",
|
||||
"compile": {
|
||||
"src_name": "solution.py",
|
||||
"exe_name": "solution.pyc",
|
||||
@ -139,6 +143,14 @@ _py2_lang_config = {
|
||||
}
|
||||
}
|
||||
_py3_lang_config = {
|
||||
"template": """//PREPEND BEGIN
|
||||
//PREPEND END
|
||||
|
||||
//TEMPLATE BEGIN
|
||||
//TEMPLATE END
|
||||
|
||||
//APPEND BEGIN
|
||||
//APPEND END""",
|
||||
"compile": {
|
||||
"src_name": "solution.py",
|
||||
"exe_name": "__pycache__/solution.cpython-35.pyc",
|
||||
|
@ -6,7 +6,7 @@ import zipfile
|
||||
from wsgiref.util import FileWrapper
|
||||
|
||||
from django.conf import settings
|
||||
from django.http import StreamingHttpResponse
|
||||
from django.http import StreamingHttpResponse, HttpResponse
|
||||
|
||||
from account.decorators import problem_permission_required
|
||||
from judge.dispatcher import SPJCompiler
|
||||
@ -67,8 +67,14 @@ class TestCaseAPI(CSRFExemptAPIView):
|
||||
with zipfile.ZipFile(file_name, "w") as file:
|
||||
for test_case in name_list:
|
||||
file.write(f"{test_case_dir}/{test_case}", test_case)
|
||||
response = StreamingHttpResponse(FileWrapper(open(file_name, "rb")), content_type="application/zip")
|
||||
if os.environ.get("OJ_ENV") == "production":
|
||||
response = HttpResponse()
|
||||
response["X-Accel-Redirect"] = file_name
|
||||
else:
|
||||
response = StreamingHttpResponse(FileWrapper(open(file_name, "rb")), content_type="application/octet-stream")
|
||||
|
||||
response["Content-Disposition"] = f"attachment; filename=problem_{problem.id}_test_cases.zip"
|
||||
response["Content-Length"] = os.path.getsize(file_name)
|
||||
return response
|
||||
|
||||
@problem_permission_required
|
||||
|
Loading…
Reference in New Issue
Block a user