Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/312.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 烧瓶:127.0.0.1--“;GET/home/n/templates/tree.jpg HTTP/1.1“;404 -_Python_Flask - Fatal编程技术网

Python 烧瓶:127.0.0.1--“;GET/home/n/templates/tree.jpg HTTP/1.1“;404 -

Python 烧瓶:127.0.0.1--“;GET/home/n/templates/tree.jpg HTTP/1.1“;404 -,python,flask,Python,Flask,这里是烧瓶新手,试图通过烧瓶显示图像 ============================================== #!/usr/bin/env python3.6 import os from flask import Flask, request, render_template, g, redirect, Response, send_from_directory tmpl_dir = os.path.join(os.path.dirname(os.path.abspa

这里是烧瓶新手,试图通过烧瓶显示图像

==============================================

#!/usr/bin/env python3.6

import os
from flask import Flask, request, render_template, g, redirect, Response, send_from_directory

tmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')
print(tmpl_dir)
app = Flask(__name__, template_folder=tmpl_dir)

@app.route('/')
def index():
    print(request.args)
    return render_template("index.html")

if __name__ == "__main__":
    app.run()
<!DOCTYPE html>
<html>
  <body>
    <h1>Text-to-Image Synthesis</h1>
    <img src="/home/n/templates/tree.jpg" width="700" height="500">
  </body>
</html>
~/server.py ==============================================

#!/usr/bin/env python3.6

import os
from flask import Flask, request, render_template, g, redirect, Response, send_from_directory

tmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')
print(tmpl_dir)
app = Flask(__name__, template_folder=tmpl_dir)

@app.route('/')
def index():
    print(request.args)
    return render_template("index.html")

if __name__ == "__main__":
    app.run()
<!DOCTYPE html>
<html>
  <body>
    <h1>Text-to-Image Synthesis</h1>
    <img src="/home/n/templates/tree.jpg" width="700" height="500">
  </body>
</html>
==============================================

#!/usr/bin/env python3.6

import os
from flask import Flask, request, render_template, g, redirect, Response, send_from_directory

tmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')
print(tmpl_dir)
app = Flask(__name__, template_folder=tmpl_dir)

@app.route('/')
def index():
    print(request.args)
    return render_template("index.html")

if __name__ == "__main__":
    app.run()
<!DOCTYPE html>
<html>
  <body>
    <h1>Text-to-Image Synthesis</h1>
    <img src="/home/n/templates/tree.jpg" width="700" height="500">
  </body>
</html>
~/templates/index.html: ==============================================

#!/usr/bin/env python3.6

import os
from flask import Flask, request, render_template, g, redirect, Response, send_from_directory

tmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')
print(tmpl_dir)
app = Flask(__name__, template_folder=tmpl_dir)

@app.route('/')
def index():
    print(request.args)
    return render_template("index.html")

if __name__ == "__main__":
    app.run()
<!DOCTYPE html>
<html>
  <body>
    <h1>Text-to-Image Synthesis</h1>
    <img src="/home/n/templates/tree.jpg" width="700" height="500">
  </body>
</html>

文本图像合成
我尝试过的事情:
  • 从_目录()发送_
  • render_模板(“index.html”,**上下文)
  • 从字面上复制代码
  • 图像
    树.jpg
    位于正确的目录中。

    按照以下步骤操作

  • tree.jpg
    移动到静态文件夹
  • 根据您的项目结构,图像的静态路径应该是
    ~/static/tree.jpg
  • 然后用,


  • 尝试了这个,图像显示出来了!我仍然得到
    不可变的multidict([])
    尽管。。。这个错误是什么意思?@platonicity你能给我看看stacktrace吗?