未提供项目描述
项目描述
Bottle Login – 在Bottle web框架中实现用户会话。
要求
python >= 2.6
安装
Bottle Login 应使用pip安装
pip install bottle-login
用法
from bottle import Bottle, request, redirect
from bottle_login import LoginPlugin
app = Bottle()
app.config['SECRET_KEY'] = 'secret'
login = app.install(LoginPlugin())
@login.load_user
def load_user_by_id(user_id):
# Load user by id here
# Some application views
@app.route('/')
def index():
current_user = login.get_user()
return current_user.name
@app.route('/signout')
def signout():
# Implement logout
login.logout_user()
return redirect('/')
@app.route('/signin')
def signin():
# Implement login (you can check passwords here or etc)
user_id = int(request.GET.get('user_id'))
login.login_user(user_id)
return redirect('/')
错误跟踪器
如果您有任何建议、错误报告或烦恼,请向https://github.com/klen/bottle-login/issues的问题跟踪器报告
贡献
Bottle Login的开发发生在:https://github.com/klen/bottle-login
贡献者
klen (Kirill Klenov)
许可
在BSD许可下许可。