本文整理匯總了Python中flask.app.Flask.static_url_path方法的典型用法代碼示例。如果您正苦於以下問題:Python Flask.static_url_path方法的具體用法?Python Flask.static_url_path怎麽用?Python Flask.static_url_path使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類flask.app.Flask
的用法示例。
在下文中一共展示了Flask.static_url_path方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: static
# 需要導入模塊: from flask.app import Flask [as 別名]
# 或者: from flask.app.Flask import static_url_path [as 別名]
##-------------------------------------------------------------------
from flask.app import Flask
from flask.templating import render_template
from flask.ext.babel import Babel, gettext as _
from datetime import date
import os
def static(filename):
"""Provides the 'static' function that also appends the file's timestamp to the URL, usable in a template."""
timestamp = os.path.getmtime(os.path.join(app.static_folder, filename))
return "%s/%s?%s" % (app.static_url_path, filename, timestamp)
app = Flask(__name__)
app.config.from_object("settings_dev")
app.static_url_path = app.config["STATIC_URL"]
app.jinja_env.globals.update(static=static)
babel = Babel(app)
greetings = ["Monday Monday, it's not always that gloomy, isn't it?",
"Happy Tuesday, is everything on track?",
"It's Wednesday, go go go!",
"It's Thursday, why not have a good dinner tonight?",
"Happy Friday, the weekend is coming.",
"Wow Saturday, how would you like to celebrate it?",
"It's Sunday, stay tuned for the upcoming great week. Are you ready for it?"]
greeting = _(greetings[date.today().weekday()])
@app.route('/')