Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在烧瓶中将图像显示为背景_Python_Html_Rest_Flask - Fatal编程技术网

Python 在烧瓶中将图像显示为背景

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

我正在介绍烧瓶应用程序的第一步。 我想知道如何显示这个图像作为背景和顶部的html文本

导入烧瓶
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()