本文介绍了Bottle.py HTTP身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取我的bottle.py应用程序(在Paste或Cherrypy中运行)以进行HTTP(基本或摘要)身份验证? -我需要保护它,但找不到任何HOWTO.
How can I get my bottle.py app (Running in Paste or Cherrypy) to do HTTP (basic or digest) authentication? - I need to secure it, but cant find a any HOWTOs.
推荐答案
瓶具有内置的auth_basic
装饰器,可用于视图:
bottle has a built in auth_basic
decorator that can be used on a view:
from bottle import auth_basic, request, route
def check(user, pw):
# Check user/pw here and return True/False
@route('/')
@auth_basic(check)
def home():
return { 'data': request.auth }
这篇关于Bottle.py HTTP身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!