autogen.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:xgovctf 作者: alphagov 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号