RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
flask框架jinja2模板与模板继承实例分析-创新互联

本文实例讲述了flask框架jinja2模板与模板继承。分享给大家供大家参考,具体如下:

成都创新互联成立于2013年,是专业互联网技术服务公司,拥有项目做网站、成都做网站网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元祁门做网站,已为上家服务,为祁门各地企业和个人服务,联系电话:13518219792

jinja2模板

from werkzeug.contrib.cache import SimpleCache
from flask import Flask, request, render_template,redirect,abort, url_for
CACHE_TIME = 300
cache = SimpleCache()
cache.timeout = CACHE_TIME
app = Flask(__name__)
@app.before_request
def return_cached():
  if not request.values:
    response = cache.get(request.path)
    if response:
      print("Got the page from cache!")
      return response
  print("Will load the page!")
@app.after_request
def cache_response(response):
  print("aaaaaaaaaaaaaaaaaaaaaa")
  if not request.values:
    cache.set(request.path, response, CACHE_TIME)
  return response
@app.teardown_request
def teardown_request(response):
  print('llllllllllllllllllllllll')
  return "llllllllllllllllllllll"
# @app.route('/')
@app.route('/get_index')
def index():
  return render_template('jinja2.html', a_variable="Developer", navigation=["http://www.163.com", "www.baidu.com"])
if __name__ == '__main__':
  app.run(port=8000)

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


分享标题:flask框架jinja2模板与模板继承实例分析-创新互联
文章位置:http://sczitong.cn/article/cdssjj.html