Commit f1d5d7ae authored by kaiyou's avatar kaiyou

Merge branch 'fix-https' into 'master'

Fix https

See merge request !1
parents 41b3d35d d0eb009e
...@@ -23,11 +23,22 @@ http { ...@@ -23,11 +23,22 @@ http {
gzip on; gzip on;
gzip_disable "msie6"; gzip_disable "msie6";
map $http_x_forwarded_proto $proxy_x_forwarded_proto {
default $http_x_forwarded_proto;
'' $scheme;
}
server { server {
listen 80; listen 80;
client_max_body_size 20M; client_max_body_size 20M;
add_header X-Frame-Options 'SAMEORIGIN';
add_header X-Content-Type-Options 'nosniff';
add_header X-Permitted-Cross-Domain-Policies 'none';
add_header X-XSS-Protection '1; mode=block';
add_header Referrer-Policy 'same-origin';
location /data { location /data {
root /; root /;
} }
...@@ -39,10 +50,10 @@ http { ...@@ -39,10 +50,10 @@ http {
location / { location / {
proxy_pass http://127.0.0.1:8000/; proxy_pass http://127.0.0.1:8000/;
proxy_set_header Host $http_host; proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
} }
} }
} }
...@@ -12,8 +12,8 @@ def get_image(root, name): ...@@ -12,8 +12,8 @@ def get_image(root, name):
""" Try and get basic image attributes. """ Try and get basic image attributes.
""" """
filename = urllib.parse.quote(os.path.basename(name)) filename = urllib.parse.quote(os.path.basename(name))
return (root + os.path.join(app.config["FULL_WEB"], filename), return (os.path.join(root, app.config["FULL_WEB"], filename),
root + os.path.join(app.config["THUMB_WEB"], filename)) os.path.join(root, app.config["THUMB_WEB"], filename))
def image_from_file(file_storage): def image_from_file(file_storage):
......
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
<footer class="page-footer blue"> <footer class="page-footer blue">
<div class="footer-copyright"> <div class="footer-copyright">
<div class="container"> <div class="container">
Built with <i class="material-icons tiny">favorite</i> using <a class="white-text" href="http://flask.pocoo.org/">Flask</a> and
<a class="white-text" href="http://materializecss.com/">Materialize</a>
<span class="right"><i class="material-icons tiny">call_split</i> on <a class="white-text" href="https://github.com/kaiyou/tedimg">Github</a>.</a> <span class="right"><i class="material-icons tiny">call_split</i> on <a class="white-text" href="https://github.com/kaiyou/tedimg">Github</a>.</a>
</div> </div>
</div> </div>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
{% block banner_content %} {% block banner_content %}
<h1 class="header center orange-text">Upload your image!</h1> <h1 class="header center orange-text">Upload your image!</h1>
<form method="post" id="upload" action="/upload" enctype="multipart/form-data"> <form method="post" id="upload" action="{{ url_for('upload') }}" enctype="multipart/form-data">
<div class="file-field input-field"> <div class="file-field input-field">
<div> <div>
<i class="material-icons left small">publish</i> <i class="material-icons left small">publish</i>
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
</div> </div>
{% endblock %} {% endblock %}
{% block section_content %} {% block section_content %}
<div class="row"> <div class="row">
<div class="col s6"> <div class="col s6">
......
...@@ -37,4 +37,4 @@ def upload(): ...@@ -37,4 +37,4 @@ def upload():
return flask.render_template("error.html", message="Could not store your image.") return flask.render_template("error.html", message="Could not store your image.")
# Save the image to a local file # Save the image to a local file
result = images.save_with_thumbnail(image, filename) result = images.save_with_thumbnail(image, filename)
return flask.redirect("/show/" + result) return flask.redirect(flask.url_for("show", path=result))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment