小编Cro*_*hat的帖子

显示创建的新网页的链接

我正在用Python构建一个网站(使用heroku),我想创建一个"最新的提交"部分.也就是说,当我@app.route(blah)在我的Python应用程序中创建一个新的时,我希望在我的主页上的"最新提交"部分下显示新页面的链接.

这可能吗?

编辑:这是我的代码

import os
import json
from flask import Flask, render_template, url_for
from werkzeug.routing import Map, Rule, NotFound, RequestRedirect, BaseConverter

app = Flask(__name__)


@app.route('/')
def index():
    return  render_template('welcome.html')

@app.route('/about', endpoint='about')
def index():
    return  render_template('about.html')

@app.route('/contact', endpoint='contact')
def index():
    return  render_template('contact.html')

@app.route('/all-links', endpoint='all-links')
def all_links():
    links = []
    for rule in app.url_map.iter_rules():
        url = url_for(rule.endpoint)
        links.append((url, rule.endpoint))
    return render_template('all_links.html', links=links)



if __name__ == '__main__':
    # Bind to PORT if defined, otherwise default to 5000.
    port = int(os.environ.get('PORT', 5000)) …
Run Code Online (Sandbox Code Playgroud)

python heroku flask

3
推荐指数
1
解决办法
3582
查看次数

标签 统计

flask ×1

heroku ×1

python ×1