markdown Flask url_for查看导航
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown Flask url_for查看导航相关的知识,希望对你有一定的参考价值。
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template('04-Home.html')
@app.route('/puppy/<name>')
def pup_name(name):
return render_template('viewNavigator.html',name=name)
if __name__ == '__main__':
app.run(debug=True)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Puppy Rock</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="{{ url_for('index') }}">Puppies Rock!</a>
</nav>
{% block content %}
{% endblock %}
</body>
</html>
{% extends "04-base.html"%}
{% block content %}
<h1>This is the page for the puppy: {{name|capitalize}}.</h1>
<a href="{{ url_for('static',filename='puppy_pic.jpg') }}">Here</a>
{% endblock %}
### url_for('#some view function name') will anchor to a view page
### url_for('#folderName',filename='#fileName') will link to a file
以上是关于markdown Flask url_for查看导航的主要内容,如果未能解决你的问题,请参考以下文章
如何把css,js文件发布到服务器上flask
flask第九篇——url_for
flask第九篇——url_for
如何将 flask.url_for() 与 flask-restful 一起使用?
[flask]jinjia2-模板 url_for的使用
flask第十篇——url_for