QQ群:476842922(欢迎加群讨论学习)
目录结构
static/
images/
test.jpg
templates/
index.html
app.py
#!/usr/bin/env python
from flask import Flask
from flask import render_template
from flask import Flask, url_for
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5050)
index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<hr />
<ul>
<li>hello world</li>
</ul>
<p><code>print hello world</code></p>
<p><img alt="Avatar" src="{{ url_for('static', filename='images/test.jpg') }}"></p>
</body>
</html>