This repository has been archived on 2026-08-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
2022-04-11 21:49:36 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
# -- coding:utf-8 --
|
|
|
|
|
# @Author: markushammered@gmail.com
|
|
|
|
|
# @Development Tool: PyCharm
|
|
|
|
|
# @Create Time: 2022/4/11
|
|
|
|
|
# @File Name: decorators.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
from flask import request
|
|
|
|
|
from flask import abort
|
|
|
|
|
from functools import wraps
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def permission_required(func):
|
|
|
|
|
@wraps(func)
|
|
|
|
|
def decorated_func(*args, **kwargs):
|
2022-04-24 21:32:04 +08:00
|
|
|
if request.args.get('key') == os.getenv('ACCESS_KEY'):
|
|
|
|
|
return func(*args, **kwargs)
|
|
|
|
|
else:
|
2022-04-11 21:49:36 +08:00
|
|
|
abort(403)
|
|
|
|
|
|
|
|
|
|
return decorated_func
|
|
|
|
|
|