【发布时间】:2018-01-16 03:09:40
【问题描述】:
我有一个网页,它从烧瓶中提供一个图片链接。我有它,所以图像在一两秒后消失。但是,如果您查看页面源代码,您仍然可以通过找到图片的确切 url 来获取图片。如何删除对 url 的访问或从 url 中删除图片,以便用户在图像消失后无法再查看图像。
HTML页面:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Welcome</title>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function () {
var c = document.getElementById('image');
console.log(typeof(c));
setTimeout(function () {
$('#des').css('visibility', 'hidden');
}, 1750);
fs.unlink("{{ url_for('static', filename = '1l1l1lI1lIlIlIlI1IlI1II1l1.jpg') }}");
removeElement(c)
storage.clear(c);
sessionStorage.clear(c);
});
</script>
<div id="des">
<img id="image" src="{{ url_for('static', filename = '1l1l1lI1lIlIlIlI1IlI1II1l1.jpg') }}"/>
</div>
</body>
</html>
main.py
from datetime import datetime
from flask import make_response
from functools import wraps, update_wrapper
from flask import Flask, request, session, g, redirect, url_for, abort, \
render_template, flash
app = Flask(__name__) # create the application instance
app.config.from_object(__name__) # load config from this file , flaskr.py
def nocache(view):
@wraps(view)
def no_cache(*args, **kwargs):
response = make_response(view(*args, **kwargs))
response.headers['Last-Modified'] = datetime.now()
response.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0'
response.headers['Pragma'] = 'no-cache'
response.headers['Expires'] = '-1'
return response
return update_wrapper(no_cache, view)
@app.route(r'/')
@nocache
def landingpage():
return render_template('index.html')
if __name__ == '__main__':
app.run()
【问题讨论】:
-
您可以通过脚本提供图像,然后在时间到时撤销访问权限,但实际上,一旦图像发送给客户端,客户端将有办法检索它,如果他们努力吧。
-
无法编辑源。您可以使用 ajax 请求加载图像并将其附加到文档中。但是,网络活动的历史记录仍然可以在浏览器控制台中找到。
-
@AliSheikhpour 将其附加到文档是什么意思?
-
例如通过ajax请求获取图片地址,设置为空图片标签的src。
$("#myimg").attr("src",imageurl);
标签: javascript python html image flask