Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.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_Python 2.7_Flask_Web Development Server - Fatal编程技术网

Python 无法使用烧瓶显示图像

Python 无法使用烧瓶显示图像,python,python-2.7,flask,web-development-server,Python,Python 2.7,Flask,Web Development Server,我想在python web应用程序的主页中显示一个图像。到目前为止,我编写了以下程序: 我的目录和文件 __初始值 views.py home.html 当我运行run.py时,我收到以下内部服务器错误: 怎么了?这不是render_template函数的正确语法。您需要使用关键字参数: return render_template('home.html', imag=imag, tle=tle) 这不是render_模板函数的正确语法。您需要使用关键字参数: return render_te

我想在python web应用程序的主页中显示一个图像。到目前为止,我编写了以下程序:

我的目录和文件

__初始值

views.py

home.html

当我运行run.py时,我收到以下内部服务器错误:


怎么了?

这不是render_template函数的正确语法。您需要使用关键字参数:

return render_template('home.html', imag=imag, tle=tle)

这不是render_模板函数的正确语法。您需要使用关键字参数:

return render_template('home.html', imag=imag, tle=tle)

您可以简单地解决Flask中的问题,最好按照中所述激活调试模式。但请确保它在生产中处于关闭状态。您可以简单地更轻松地解决Flask中的问题。激活调试模式是一个好主意,如中所述。但要确保它在生产过程中关闭。
from app import app
from flask import render_template
from flask import url_for

@app.route('/')
def root():
    imag = url_for ('static', filename = 'Desert.jpg')
    tle = "Hey"
    return render_template('home.html', imag,tle)
<html>
    <title>{{ tle }}</title>
    <body>
        <img src="{{ imag }}"/>
    </body>
</html>
from app import app
if __name__ == "__main__":
    app.run()
return render_template('home.html', imag=imag, tle=tle)