Commit d0eb009e authored by kaiyou's avatar kaiyou

Use url_for properly across the application

parent 62b1a187
......@@ -12,8 +12,8 @@ def get_image(root, name):
""" Try and get basic image attributes.
"""
filename = urllib.parse.quote(os.path.basename(name))
return (root + os.path.join(app.config["FULL_WEB"], filename),
root + os.path.join(app.config["THUMB_WEB"], filename))
return (os.path.join(root, app.config["FULL_WEB"], filename),
os.path.join(root, app.config["THUMB_WEB"], filename))
def image_from_file(file_storage):
......
......@@ -2,7 +2,7 @@
{% block banner_content %}
<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>
<i class="material-icons left small">publish</i>
......
......@@ -11,7 +11,6 @@
</div>
{% endblock %}
{% block section_content %}
<div class="row">
<div class="col s6">
......
......@@ -37,4 +37,4 @@ def upload():
return flask.render_template("error.html", message="Could not store your image.")
# Save the image to a local file
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