html登陆不刷新flask,Web:Flask/JS多久刷新一次?

我想让图像只在我的机器上实时显示。想想谷歌图片的基本版本吧。用户输入“红色锤子”,我给他们看一张红色锤子的图片

问题是刷新率。我更新要显示的图像文件,当我直接将其作为http://127.0.0.1:6007/static/tree.jpg查找时,会立即得到最新的jpg。然后,奇怪的是,在我查找类似http://127.0.0.1:6007/static/tree.jpg的内容后,图像在初始的http://127.0.0.1:6007上发生了变化!在

我的设置:

在static/目录中,tree.jpg:

da40ac40d46c79f5678d45a1a7c7b081.png

模板/

在显示.html

在templates/,show.html:

Text-to-Image Synthesis

Input to Generator:

%7B%7Burl_for('static',%20filename='tree.jpg')%7D%7D

在索引.html

和index.html:

^{pr2}$

除了show.html显示src=...行上的图像外,这两个是相同的。在

在服务器.py在#!/usr/bin/env python2.7

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')

app = Flask(__name__, template_folder=tmpl_dir)

@app.route('/')

def index():

return render_template("index.html")

@app.route('/generator', methods=['POST'])

def generator():

# save typed-in text

text = request.form['input_text']

filename = "/home/ubuntu/icml2016/scripts/cub_queries.txt"

with open(filename, "a+") as f:

f.write(text + "\n")

"""

print('start')

subprocess.call('./scripts/demo_cub.sh', shell=True) # change the image in the background

print('end')

"""

return render_template("show.html")

if __name__ == "__main__":

HOST='0.0.0.0'

PORT=6007

app.run(host=HOST, port=PORT)

所以现在如果我把所有的东西都给了你,你应该可以打电话给python3 server.py并看到这个:

Wg41h.png

如果您在框中输入“嗨”,它将显示以下内容:

uDc7z.png

但当我改变树.jpg到背景中的其他图像并输入其他内容,我无法获得我正在寻找的即时图像更新。换句话说,那棵树不会成为最近的一棵树:(我们想在我的基本网页上看到莫里美丽的脸。)

evTM2.jpg

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值