Skip to content

Commit

Permalink
删除临时代码文件,并设置回复信息的最大行数与最大长度
Browse files Browse the repository at this point in the history
  • Loading branch information
shengan committed May 29, 2024
1 parent 8896c9b commit cd667c9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions python/server.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import datetime
import os

from sanic import Sanic
from sanic import text
Expand All @@ -26,9 +27,12 @@ async def run_code(request):
)
stdout, stderr = await proc.communicate()
msg = stdout.decode() + stderr.decode()
os.remove(fname)

_msg = msg.split('\n')[:15]
res = '\n'.join(_msg)
max_line = os.getenv('OUTPUT_MAX_LINE', 15)
max_len = os.getenv('OUTPUT_MAX_LEN', 256)
_msg = msg.split('\n')[:max_line]
res = '\n'.join(_msg)[:max_len]
return text(res)


Expand Down

0 comments on commit cd667c9

Please sign in to comment.