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

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 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券