def serve_autogen_hook(path):
pid = request.args.get("pid", None)
static = request.args.get("static", "false") == "true"
tid = api.user.get_team()["tid"]
if pid not in api.problem.get_unlocked_pids(tid):
return WebError("You have not unlocked this problem!")
instance_number = api.autogen.get_instance_number(pid, tid)
if static:
instance_path = api.autogen.get_static_instance_path(pid, public=True)
else:
instance_path = api.autogen.get_instance_path(pid, instance_number, public=True)
mime = guess_mimetype(path)
if mime == 'text/html':
return send_from_directory(instance_path, path, mimetype=None, as_attachment=False, attachment_filename=None)
else:
return send_from_directory(instance_path, path, mimetype=mime)
评论列表
文章目录