我已经创建了一个烧瓶应用程序,我会限制添加一个烧瓶限制器也。它打算让用户每分钟使用一次路线。如果用户再次尝试,它将重定向到自定义429页面。在localhost上,它工作得绝对完美,但是在将它提交到我的Heroku应用程序时,限制器不会阻止多次使用路由。它也不会重定向到429页
app = Flask(__name__)
limiter = Limiter(
app,
key_func=get_remote_address,
default_limits=["200 per day", "50 per hour"]
)
@main_bp.route('/main', methods=['POST'])
@limiter.limit("1/minute")
def text_sum():
the code blah blah blah
@main_bp.errorhandler(429)
def ratelimit_handler(e):
return render_template('main429.html', result = "Please try again in 1 minute")
正如v25所述-我只是将procfile更改为:
相关问题 更多 >
编程相关推荐