zoomed images page

master
suzan 1 year ago
parent ea82081219
commit 7b527530ae

@ -65,3 +65,31 @@ def upload_file():
# f = request.files['the_file']
# f.save('/var/www/uploads/uploaded_file.txt')
#to refer backto zoomreplace.html
@app.route('/image/static/img/<imgpath>')
def zoomedimage(imgpath):
print (imgpath)
return render_template("zoomreplace.html", image=imgpath)
@app.route('/upload2/<image>', methods=['POST'])
def upload2_file(image):
if request.method == 'POST':
file = request.files['tile']
if file and allowed_file(file.filename):
filename, fileextension = os.path.splitext(file.filename)
overwrite = image #00.png
input_file_path = os.path.join(app.config['UPLOAD_FOLDER'], filename + fileextension)
overwritten_file_path = os.path.join(app.config['UPLOAD_FOLDER'], overwrite)
print("[input file path]:", input_file_path)
print("[overwritten file path]:", overwritten_file_path)
if 'png' not in fileextension:
print("--- convert uploaded image to png")
cmd = f"convert { input_file_path } { overwritten_file_path }"
os.system(cmd)
file.save(overwritten_file_path)
return redirect("/")

@ -9,6 +9,8 @@
width: 10%;
margin: 0;
padding: 0;
object-fit: cover;
height: 14%;
}
img:hover{
filter: invert(1);
@ -16,7 +18,7 @@
</style>
</head>
<body>
{% for image in images %}<img src="{{ image }}">{% endfor %}
{% for image in images %}<a href="/image/{{image}}"><img src="{{ image }}"></a>{% endfor %}
<form action="/upload/" method="POST" enctype="multipart/form-data">
<label for="tile">Choose an image to upload:</label>

@ -0,0 +1,13 @@
<html>
<head>
</head>
<body>
<img src="/static/img/{{ image }}">
<form action="/upload2/{{image}}" method="POST" enctype="multipart/form-data">
<label for="tile">Choose an image to upload:</label>
<input type="file"
id="tile" name="tile" required>
<input type="submit" value="Upload">
</form>
</body>
</html>
Loading…
Cancel
Save