我试过使用@fontface css样式,但字体无法呈现。 使用python/flask还有其他方法吗??
<!DOCTYPE html>
<html>
<style type="text/css">
@font-face {
font-family: trial;
src: url_for('CENTRALESANSCND-BOLD.otf') ;
font-weight:bold; }
</style>
<body>
<p style="font-family:trial; font-weight: bold"> Hello </p>
</body>
</html>
上面是我的HTML模板。 不幸的是,当我使用Flask渲染时,它没有反映字体。 下面是我的.py代码:
from flask import Flask, render_template
app=Flask(__name__)
app.secret_key='1234'
@app.route('/', methods=['post', 'get'])
def output():
c=2+3
print c
return render_template('f.html', c=c)
if __name__=='__main__':
app.run(port=9876)
url_for接受函数名,需要用双花括号将其括起来。。。尝试:
非常感谢你的帮助。。所有建议的结合终于奏效了。
在此处发布解决方案:
CSS文件:
HTML文件:
相关问题 更多 >
编程相关推荐