/flask-avatar

To generate avatar for flask

Primary LanguagePythonBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

flask-avatar

https://img.shields.io/badge/pypi-v0.1.2-brightgreen.svg https://img.shields.io/badge/python-3.4-brightgreen.svg https://img.shields.io/badge/license-BSD-blue.svg

Example

https://raw.githubusercontent.com/honmaple/flask-avatar/master/example/avatar1.png https://raw.githubusercontent.com/honmaple/flask-avatar/master/example/avatar2.png https://raw.githubusercontent.com/honmaple/flask-avatar/master/example/avatar3.png

Installation

To install Flask-Avatar:

pip install flask-avatar

Or alternatively, you can download the repository and install manually by doing:

git clone git@github.com:honmaple/flask-avatar.git
cd flask-avatar
python setup.py install

Usage

from flask_avatar import Avatar
[...]
Avatar(app)

Templates:

{{ url_for('avatar',text = user.username )}}

or set width with:

{{ url_for('avatar',text = user.username,width=60)}}

Config

AVATAR_URL = '/avatar' #The avatar url,default '/avatar/<text>/<width>'
AVATAR_RANGE = [0,512] #set avatar range to allow generate,if disallow,abort(404).Default [0,512]

Thanks to

https://github.com/maethor/avatar-generator