committing martinos updates

master
xpub1 1 year ago
parent d3473d69ec
commit fca0aee1e3

@ -8,3 +8,6 @@ local:
breadcube:
@SCRIPT_NAME=${OVERLAP_APPLICATION_ROOT} gunicorn -b localhost:${OVERLAP_PORTNUMBER} --reload app:app
breadcube2:
@SCRIPT_NAME=${OVERLAP_APPLICATION_ROOT} gunicorn -b localhost:${OVERLAP_PORTNUMBER} --reload app2:app

@ -0,0 +1,128 @@
# This is a flask application that overlaps uploaded images and text on top of images laid out in a grid on the browser.
from flask import Flask
from flask import request, redirect
from flask import render_template
import glob
import os
from shutil import copyfile, move
from datetime import datetime
UPLOAD_FOLDER = os.path.join("static", "img")
ALLOWED_EXTENSIONS = {'txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif', 'mp3', 'm4a', 'ogg', 'ogv', 'mp4', 'mkv'}
def allowed_file(filename):
return '.' in filename and \
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
def lastupload(imgpath):
files = glob.glob('./static/img/' + imgpath[0:2] + '/*')
files.sort(reverse=True)
return files[0]
# create flask application
app = Flask(__name__)
# configure the upload folder
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
# load the settings of the applicaiton
# (to handle the routing correctly)
app.config.from_pyfile('settings.py')
@app.route("/")
def overlap():
lastfiles = []
for i in range (0,42):
last=lastupload(str(i).zfill(2))
lastfiles.append(last)
images = glob.glob('./static/img/*.png')
images.sort()
print(images)
print(lastfiles)
return render_template("mosaic2.html", lastfiles=lastfiles, images=images)
from flask import request
@app.route('/upload/', methods=['POST'])
def upload_file():
if request.method == 'POST':
file = request.files['tile']
if file and allowed_file(file.filename):
filename, fileextension = os.path.splitext(file.filename)
overwrite = request.form["overwrite"]
input_file_path = os.path.join(app.config['UPLOAD_FOLDER'], overwrite + '/' + filename + fileextension)
overwritten_file_path = os.path.join(app.config['UPLOAD_FOLDER'], overwrite + fileextension)
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(input_file_path)
file.save(overwritten_file_path)
# print("==============================================================")
# print(fileextension)
# print(f"copy { UPLOAD_FOLDER + file.filename} { UPLOAD_FOLDER + overwrite + fileextension }")
# os.system(f"copy { UPLOAD_FOLDER + file.filename} { UPLOAD_FOLDER + overwrite + fileextension }")
# print(f"del { UPLOAD_FOLDER + file.filename }")
# os.system(f"del { UPLOAD_FOLDER + file.filename }")
return redirect("/")
# 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)
# list the files in imgpath[0:2], pass them to template
files = glob.glob('./static/img/' + imgpath[0:2] + '/*')
files.sort(reverse=True)
print(files)
return render_template("zoomreplace2.html", image=imgpath, files=files )
@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 = os.path.splitext(image)[0] #00 . png
input_file_path = os.path.join(app.config['UPLOAD_FOLDER'], overwrite + '/' + filename + fileextension)
# overwritten_file_path = os.path.join(app.config['UPLOAD_FOLDER'], overwrite + fileextension)
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)
# save it in the main folder with the number as the name
file.save(input_file_path)
# file.save(overwritten_file_path)
# and save it in the folder with the date as the name
number_folder = image[0:2]
datething = str(datetime.now()).replace(":", "").replace(" ", "").replace("-", "").replace(".", "")
print(datething)
memory_file_path = os.path.join(app.config['UPLOAD_FOLDER'],number_folder, datething + fileextension)
print(memory_file_path)
# tempfile.save(memory_file_path)
move(input_file_path, memory_file_path)
return redirect("/breadcube/overlap/")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 327 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 259 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 314 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 946 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 946 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 905 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 905 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 308 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

After

Width:  |  Height:  |  Size: 366 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 385 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 385 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 605 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 230 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 155 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 439 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 485 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 574 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 244 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 366 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 925 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 925 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 926 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 980 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 980 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 754 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save