flask avatars从gravatar获得头像(flask 81)

2019-08-20 16:52:22 浏览数 (1)

从https://en.gravatar.com/获得头像

from flask import Flask, render_template from flask_avatars import Avatars

app = Flask(name) avatars = Avatars(app)

@app.route('/') def index(): email_hash = hashlib.md5('test@helloflask.com'.lower().encode('utf-8')).hexdigest() return render_template('index.html', email_hash=email_hash)

html

<p>{% raw %}{{ avatars.gravatar(email_hash) }}{% endraw %}: <img src="{{ avatars.gravatar(email_hash) }}"></p> <p>{% raw %}{{ avatars.gravatar(email_hash, size='200', default='monsterid') }}{% endraw %}: <img src="{{ avatars.gravatar(email_hash, size='200', default='monsterid') }}"></p>

0 人点赞