test development python django-66. Picture 403forbidden

Foreword

Development of web pages with django, when you add a picture on an HTML page, find local images can be normal, but add a picture of the Internet, but can not display properly.

Local static picture

First put in the local static picture yy.png, html img tags for your images inside address for the local address of the picture: static / yy.png

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>


<p>本地图片连接</p>
<img   src="static/yy.png">

</body>
</html>

In the browser can display normal picture

External images

Find a picture on the Internet, such as my public image two-dimensional code number Address: https://images2018.cnblogs.com/blog/1070438/201806/1070438-20180601092830072-1349216615.png
img tags in html inside the src Internet address set to this picture

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">

    <title>Title</title>
</head>
<body>


<p>本地图片连接</p>
<img   src="static/yy.png">

<p>外部网站图片</p>
<img width="300" height="300"  src="https://images2018.cnblogs.com/blog/1070438/201806/1070438-20180601092830072-1349216615.png">

</body>
</html>

Time of the visit, can not find the picture display, return 403 forbidden

Solution

About referrer, said to be a reference strategy can be used to prevent pictures or videos stolen. Its principle is: http protocol, if the jump from one page to another web page, http header fields which will take a Referrer.
Pictures from the server by detecting whether or not the provisions of Referrer domain name, to the security chain. If no referrer, you can bypass the security chain mechanism, directly or stolen.

The reason no-referrer-when-downgrade is because they do not comply with security policies send a referrer, the solution is at the head of his party

<meta name="referrer" content="no-referrer" />
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="referrer" content="no-referrer" />
    <title>Title</title>
</head>
<body>

<p>本地图片连接</p>
<img   src="static/yy.png">

<p>这是一张图片</p>
<img width="300" height="300"  src="https://images2018.cnblogs.com/blog/1070438/201806/1070438-20180601092830072-1349216615.png">

</body>
</html>

Guess you like

Origin www.cnblogs.com/yoyoketang/p/11796674.html