flask 使用flask_moment

2019-07-07 15:15:07 浏览数 (1)

//不要和bootstrap同时使用,会冲突 from flask import Flask from flask import render_template from flask_moment import Moment from datetime import datetime

app = Flask(name) moment = Moment(app)

@app.route('/moment') def moment(): return render_template('moment.html',current_time=datetime.utcnow())

if name == 'main': app.run()

//moment.html <html> <head> {{ moment.include_jquery() }} {{ moment.include_moment() }}    {{ moment.lang("zh-CN") }} </head> <body> <p>现在时间时: {{ moment().format('YYYY年M月D日, h:mm:ss a') }}.</p> <p>The local date and time is {{ moment(current_time).format('LLL') }}</p> <p>That was {{ moment(current_time).fromNow(refresh=True) }}</p> <p>{{ moment().calendar() }}.</p> </body> </html>

0 人点赞