Python 在烧瓶中将图像显示为背景
我正在介绍烧瓶应用程序的第一步。 我想知道如何显示这个图像作为背景和顶部的html文本Python 在烧瓶中将图像显示为背景,python,html,rest,flask,Python,Html,Rest,Flask,我正在介绍烧瓶应用程序的第一步。 我想知道如何显示这个图像作为背景和顶部的html文本 导入烧瓶 app=烧瓶。烧瓶(\uuuuu名称\uuuuuuu) app.config[“DEBUG”]=True @app.route('/',方法=['GET']) def home(): return“欢迎使用API服务”此网站是一个用于显示仪表盘的原型API:快速报告、犯罪定位器。” app.run() 最优雅的解决方法是使用模板。 第一步是创建一个静态和模板目录,如下所示: --static
导入烧瓶
app=烧瓶。烧瓶(\uuuuu名称\uuuuuuu)
app.config[“DEBUG”]=True
@app.route('/',方法=['GET'])
def home():
return“欢迎使用API服务”此网站是一个用于显示仪表盘的原型API:快速报告、犯罪定位器。”
app.run()
最优雅的解决方法是使用模板。第一步是创建一个静态和模板目录,如下所示:
--static
|
-- image.png
-- templates
|
-- index.html
--app.py
index.html
<style>
body {
background-image: url("/static/image.png");
}
</style>
<body>
<h1>Welcome to the API Service</h1>
<p>This site is a prototype API for displaying dashboards: quick_report,crime_locator.</p>
</body>
<style>
body {
background-image: url("/static/image.png");
}
</style>
<body>
<h1>Welcome to the API Service</h1>
<p>This site is a prototype API for displaying dashboards: quick_report,crime_locator.</p>
</body>
import flask
app = flask.Flask(__name__, static_folder="static")
app.config["DEBUG"] = True
@app.route('/', methods=['GET'])
def home():
return flask.render_template('index.html')
app.run()