diff --git a/app.py b/app.py index 6cade46..6737c95 100644 --- a/app.py +++ b/app.py @@ -1,23 +1,21 @@ # -*- coding: utf-8 -*- -from flask import Flask, render_template, request, flash, redirect, url_for +from flask import Flask, render_template, request, flash, redirect, url_for, send_file from werkzeug.utils import secure_filename -import os, secrets +import os +import secrets from models import db, PrintedDetal import logging logging.basicConfig(filename='app.log', encoding='utf-8', level=logging.DEBUG) -UPLOAD_IMG_FOLDER = os.path.join('static', 'img', 'uploads') -UPLOAD_STL_FOLDER = os.path.join('static', 'stl') -ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'stl'} - app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///app.db' -app.config['UPLOAD_FOLDER'] = UPLOAD_IMG_FOLDER -app.config['UPLOAD_FOLDER2'] = UPLOAD_STL_FOLDER +app.config['UPLOAD_IMG_FOLDER'] = os.path.join('static', 'uploads', 'img') +app.config['UPLOAD_STL_FOLDER'] = os.path.join('static', 'uploads', 'stl') +app.config['UPLOAD_SRC_FOLDER'] = os.path.join('static', 'uploads', 'src') -db.init_app(app) +db.init_app(app) @app.route("/") @@ -27,74 +25,73 @@ def index(): detalsQuery = PrintedDetal.query.all() - - for detal in detalsQuery: detals = {} detals['img'] = detal.img - detals['stl'] = detal.stl - detals['src']= detal.src + detals['stl'] = detal.stl + detals['src'] = detal.src detals['isprinted'] = detal.isprinted - + allDetals[detal.id] = detals - - print(allDetals) - + logging.debug(allDetals) - return render_template("index.html") # , detals=detals) + return render_template("index.html", detals=allDetals) @app.route("/admin", methods=['GET', 'POST']) def admipage(): logging.debug("adminpage loaded") - + return render_template("adminpage.html") @app.route('/uploader', methods=['GET', 'POST']) def upload_file(): - hex = secrets.token_hex(15) - - if request.method == 'POST': - image_file = request.files['imgfile'] - stl_file = request.files['stlfile'] - src_file = request.files['stlfile'] + image_file = request.files['img'] + stl_file = request.files['stl'] + src_file = request.files['src'] if len(image_file.filename) > 0: - image_file.save(os.path.join(app.config['UPLOAD_FOLDER'], secure_filename(image_file.filename))) - - if len(stl_file.filename) >0: - stl_file.save(os.path.join(app.config['UPLOAD_FOLDER2'], secure_filename(stl_file.filename))) - - if len(src_file.filename) >0: - src_file.save(os.path.join(app.config['UPLOAD_FOLDER2'], secure_filename(src_file.filename))) + filename = image_file.filename.split('.') + image_file.filename = secrets.token_hex(15) + '.' + filename[-1] + image_file.save(os.path.join( + app.config['UPLOAD_IMG_FOLDER'], image_file.filename)) + if len(stl_file.filename) > 0: + filename = stl_file.filename.split('.') + stl_file.filename = secrets.token_hex(15) + '.' + filename[-1] + stl_file.save(os.path.join(app.config['UPLOAD_STL_FOLDER'],stl_file.filename)) + + if len(src_file.filename) > 0: + filename = src_file.filename.split('.') + src_file.filename = secrets.token_hex(15) + '.' + filename[-1] + src_file.save(os.path.join(app.config['UPLOAD_SRC_FOLDER'], src_file.filename)) - if request.form.get('isprinted') == 'on': isprinered = True else: isprinered = False - - logging.debug(image_file) - logging.debug(stl_file) + logging.debug(image_file.filename) + logging.debug(stl_file.filename) + logging.debug(src_file.filename) logging.debug(isprinered) detal = PrintedDetal(img=image_file.filename, - stl=stl_file.filename, - src=src_file.filename, - isprinted=isprinered) + stl=stl_file.filename, + src=src_file.filename, + isprinted=isprinered) db.session.add(detal) db.session.commit() - return redirect(url_for('admipage')) - + +@app.route('/download/', methods=['GET', 'POST']) +def download(filename): + return send_file(app.config['UPLOAD_SRC_FOLDER']+'/'+ filename, as_attachment=True) if __name__ == "__main__": app.run(host="0.0.0.0", debug="True", port="3800") - diff --git a/static/css/style.css b/static/css/style.css index 12eb775..b60fbb9 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -30,8 +30,13 @@ header { background-color: #fef6dd; border-radius: 12px; box-shadow: 0px 5px 10px 2px rgba(34, 60, 80, 0.2); + height: 450px; } +.card-img-top{ + + height: 250px; +} .btn { diff --git a/static/img/uploads/13c3a23110f9ae0a8c6c2eaf153ce3.jpg b/static/img/uploads/13c3a23110f9ae0a8c6c2eaf153ce3.jpg new file mode 100644 index 0000000..78407d5 Binary files /dev/null and b/static/img/uploads/13c3a23110f9ae0a8c6c2eaf153ce3.jpg differ diff --git a/static/img/uploads/1a47072defc8d6e06c5432bfa94ff9.jpg b/static/img/uploads/1a47072defc8d6e06c5432bfa94ff9.jpg new file mode 100644 index 0000000..cfd993e Binary files /dev/null and b/static/img/uploads/1a47072defc8d6e06c5432bfa94ff9.jpg differ diff --git a/static/img/uploads/1e6372b9451aa8d5325b295ac64d40.jpg b/static/img/uploads/1e6372b9451aa8d5325b295ac64d40.jpg new file mode 100644 index 0000000..78407d5 Binary files /dev/null and b/static/img/uploads/1e6372b9451aa8d5325b295ac64d40.jpg differ diff --git a/static/img/uploads/280c7fe9388d4f445100acc1b7b1ac.jpg b/static/img/uploads/280c7fe9388d4f445100acc1b7b1ac.jpg new file mode 100644 index 0000000..78407d5 Binary files /dev/null and b/static/img/uploads/280c7fe9388d4f445100acc1b7b1ac.jpg differ diff --git a/static/img/uploads/4fb140f1adecd3aae5e697ed2b3107.png b/static/img/uploads/4fb140f1adecd3aae5e697ed2b3107.png new file mode 100644 index 0000000..a543494 Binary files /dev/null and b/static/img/uploads/4fb140f1adecd3aae5e697ed2b3107.png differ diff --git a/static/img/uploads/73e726fde93f0c81141140007e2f6a.jpg b/static/img/uploads/73e726fde93f0c81141140007e2f6a.jpg new file mode 100644 index 0000000..cfd993e Binary files /dev/null and b/static/img/uploads/73e726fde93f0c81141140007e2f6a.jpg differ diff --git a/static/img/uploads/8907a42ceb726bc28f1f254323d291.png b/static/img/uploads/8907a42ceb726bc28f1f254323d291.png new file mode 100644 index 0000000..e081c66 Binary files /dev/null and b/static/img/uploads/8907a42ceb726bc28f1f254323d291.png differ diff --git a/static/img/uploads/a8839944bcde4fb39480a891338293.png b/static/img/uploads/a8839944bcde4fb39480a891338293.png new file mode 100644 index 0000000..a543494 Binary files /dev/null and b/static/img/uploads/a8839944bcde4fb39480a891338293.png differ diff --git a/static/img/uploads/b0ba34fd7f2cb29f16d22cdf64f3cd.png b/static/img/uploads/b0ba34fd7f2cb29f16d22cdf64f3cd.png new file mode 100644 index 0000000..d6adae9 Binary files /dev/null and b/static/img/uploads/b0ba34fd7f2cb29f16d22cdf64f3cd.png differ diff --git a/static/img/uploads/d85d9441ce77db404a7a3624c6a4c5.png b/static/img/uploads/d85d9441ce77db404a7a3624c6a4c5.png new file mode 100644 index 0000000..e081c66 Binary files /dev/null and b/static/img/uploads/d85d9441ce77db404a7a3624c6a4c5.png differ diff --git a/static/img/uploads/de2b9c1eb3aa4b51d8b904c2eb9ebd.jpg b/static/img/uploads/de2b9c1eb3aa4b51d8b904c2eb9ebd.jpg new file mode 100644 index 0000000..cfd993e Binary files /dev/null and b/static/img/uploads/de2b9c1eb3aa4b51d8b904c2eb9ebd.jpg differ diff --git a/static/img/uploads/f5daf4603ed462e2093415fce3c357.png b/static/img/uploads/f5daf4603ed462e2093415fce3c357.png new file mode 100644 index 0000000..23695e3 Binary files /dev/null and b/static/img/uploads/f5daf4603ed462e2093415fce3c357.png differ diff --git a/static/src/2.bp.blogspot.com_-7f4a1d8186b5463f1a8c26a52eda0a85.jpg b/static/src/2.bp.blogspot.com_-7f4a1d8186b5463f1a8c26a52eda0a85.jpg new file mode 100644 index 0000000..e69de29 diff --git a/static/src/aprendiendodedibujotecnico1003.blogspot.com_SISTEMAS-DE-PROYECCINacbe924805b36206ba452ec671943a58.jpg b/static/src/aprendiendodedibujotecnico1003.blogspot.com_SISTEMAS-DE-PROYECCINacbe924805b36206ba452ec671943a58.jpg new file mode 100644 index 0000000..e69de29 diff --git a/static/src/c642733f147aec6642e3e2130f6f84.png b/static/src/c642733f147aec6642e3e2130f6f84.png new file mode 100644 index 0000000..e69de29 diff --git a/static/stl/2.bp.blogspot.com_-7f4a1d8186b5463f1a8c26a52eda0a85.jpg b/static/stl/2.bp.blogspot.com_-7f4a1d8186b5463f1a8c26a52eda0a85.jpg new file mode 100644 index 0000000..cfd993e Binary files /dev/null and b/static/stl/2.bp.blogspot.com_-7f4a1d8186b5463f1a8c26a52eda0a85.jpg differ diff --git a/static/stl/aprendiendodedibujotecnico1003.blogspot.com_SISTEMAS-DE-PROYECCINacbe924805b36206ba452ec671943a58.jpg b/static/stl/aprendiendodedibujotecnico1003.blogspot.com_SISTEMAS-DE-PROYECCINacbe924805b36206ba452ec671943a58.jpg new file mode 100644 index 0000000..78407d5 Binary files /dev/null and b/static/stl/aprendiendodedibujotecnico1003.blogspot.com_SISTEMAS-DE-PROYECCINacbe924805b36206ba452ec671943a58.jpg differ diff --git a/static/stl/autocadparatodos.blogspot.com_Acotado-e-Impresin-de-un-slido-3D-2-de-2-Auto7f251170e47a20eb87d8ab46c8bd0219.png b/static/stl/autocadparatodos.blogspot.com_Acotado-e-Impresin-de-un-slido-3D-2-de-2-Auto7f251170e47a20eb87d8ab46c8bd0219.png new file mode 100644 index 0000000..e081c66 Binary files /dev/null and b/static/stl/autocadparatodos.blogspot.com_Acotado-e-Impresin-de-un-slido-3D-2-de-2-Auto7f251170e47a20eb87d8ab46c8bd0219.png differ diff --git a/static/uploads/img/39336ea1bd63cd729256a4840f58eb.jpg b/static/uploads/img/39336ea1bd63cd729256a4840f58eb.jpg new file mode 100644 index 0000000..78407d5 Binary files /dev/null and b/static/uploads/img/39336ea1bd63cd729256a4840f58eb.jpg differ diff --git a/static/uploads/img/47f8eaffbd6afb256d0c30d4537755.jpg b/static/uploads/img/47f8eaffbd6afb256d0c30d4537755.jpg new file mode 100644 index 0000000..cfd993e Binary files /dev/null and b/static/uploads/img/47f8eaffbd6afb256d0c30d4537755.jpg differ diff --git a/static/uploads/img/52d8fefb9d1ffed4b85b0a4dc09365.jpg b/static/uploads/img/52d8fefb9d1ffed4b85b0a4dc09365.jpg new file mode 100644 index 0000000..78407d5 Binary files /dev/null and b/static/uploads/img/52d8fefb9d1ffed4b85b0a4dc09365.jpg differ diff --git a/static/uploads/img/5e616db251a1f79f500d9a88a6c524.jpg b/static/uploads/img/5e616db251a1f79f500d9a88a6c524.jpg new file mode 100644 index 0000000..cfd993e Binary files /dev/null and b/static/uploads/img/5e616db251a1f79f500d9a88a6c524.jpg differ diff --git a/static/uploads/img/6adf0d6e7152f32e26cac5dc8d9bf1.png b/static/uploads/img/6adf0d6e7152f32e26cac5dc8d9bf1.png new file mode 100644 index 0000000..23695e3 Binary files /dev/null and b/static/uploads/img/6adf0d6e7152f32e26cac5dc8d9bf1.png differ diff --git a/static/uploads/img/780bc1f4b169cb3cb4b0b5817152cb.png b/static/uploads/img/780bc1f4b169cb3cb4b0b5817152cb.png new file mode 100644 index 0000000..a543494 Binary files /dev/null and b/static/uploads/img/780bc1f4b169cb3cb4b0b5817152cb.png differ diff --git a/static/uploads/img/7f77be274a610e1110778492813e58.png b/static/uploads/img/7f77be274a610e1110778492813e58.png new file mode 100644 index 0000000..e081c66 Binary files /dev/null and b/static/uploads/img/7f77be274a610e1110778492813e58.png differ diff --git a/static/uploads/img/a8972714142d6ce089a7748a52d176.jpg b/static/uploads/img/a8972714142d6ce089a7748a52d176.jpg new file mode 100644 index 0000000..78407d5 Binary files /dev/null and b/static/uploads/img/a8972714142d6ce089a7748a52d176.jpg differ diff --git a/static/uploads/src/070105ef12aa09da5f8745b26c1b00.jpg b/static/uploads/src/070105ef12aa09da5f8745b26c1b00.jpg new file mode 100644 index 0000000..78407d5 Binary files /dev/null and b/static/uploads/src/070105ef12aa09da5f8745b26c1b00.jpg differ diff --git a/static/uploads/src/366d577969a8f6c3d3dcde95b7c36e.png b/static/uploads/src/366d577969a8f6c3d3dcde95b7c36e.png new file mode 100644 index 0000000..23695e3 Binary files /dev/null and b/static/uploads/src/366d577969a8f6c3d3dcde95b7c36e.png differ diff --git a/static/uploads/src/54a029e3d30e2d293935d561284604.png b/static/uploads/src/54a029e3d30e2d293935d561284604.png new file mode 100644 index 0000000..e081c66 Binary files /dev/null and b/static/uploads/src/54a029e3d30e2d293935d561284604.png differ diff --git a/static/uploads/src/95442dae6cdf2be5c7bb883ec460ff.jpg b/static/uploads/src/95442dae6cdf2be5c7bb883ec460ff.jpg new file mode 100644 index 0000000..cfd993e Binary files /dev/null and b/static/uploads/src/95442dae6cdf2be5c7bb883ec460ff.jpg differ diff --git a/static/uploads/src/a13c81558c5484445cf9dc33a0a4f3.jpg b/static/uploads/src/a13c81558c5484445cf9dc33a0a4f3.jpg new file mode 100644 index 0000000..78407d5 Binary files /dev/null and b/static/uploads/src/a13c81558c5484445cf9dc33a0a4f3.jpg differ diff --git a/static/uploads/src/ad33b76d2e6d1ee725c95b4b8eba4d.png b/static/uploads/src/ad33b76d2e6d1ee725c95b4b8eba4d.png new file mode 100644 index 0000000..a543494 Binary files /dev/null and b/static/uploads/src/ad33b76d2e6d1ee725c95b4b8eba4d.png differ diff --git a/static/uploads/src/aprendiendodedibujotecnico1003.blogspot.com_SISTEMAS-DE-PROYECCINacbe924805b36206ba452ec671943a58.jpg b/static/uploads/src/aprendiendodedibujotecnico1003.blogspot.com_SISTEMAS-DE-PROYECCINacbe924805b36206ba452ec671943a58.jpg new file mode 100644 index 0000000..78407d5 Binary files /dev/null and b/static/uploads/src/aprendiendodedibujotecnico1003.blogspot.com_SISTEMAS-DE-PROYECCINacbe924805b36206ba452ec671943a58.jpg differ diff --git a/static/uploads/src/f5abf0156af9fafeb560caee9d8dd2.jpg b/static/uploads/src/f5abf0156af9fafeb560caee9d8dd2.jpg new file mode 100644 index 0000000..cfd993e Binary files /dev/null and b/static/uploads/src/f5abf0156af9fafeb560caee9d8dd2.jpg differ diff --git a/static/uploads/stl/5043eb896ce1a9e7a1a12a1e1a9d63.jpg b/static/uploads/stl/5043eb896ce1a9e7a1a12a1e1a9d63.jpg new file mode 100644 index 0000000..78407d5 Binary files /dev/null and b/static/uploads/stl/5043eb896ce1a9e7a1a12a1e1a9d63.jpg differ diff --git a/static/uploads/stl/8a9ac33bb865b3a4c5a9b2b538f01a.png b/static/uploads/stl/8a9ac33bb865b3a4c5a9b2b538f01a.png new file mode 100644 index 0000000..e081c66 Binary files /dev/null and b/static/uploads/stl/8a9ac33bb865b3a4c5a9b2b538f01a.png differ diff --git a/static/uploads/stl/a483b6fdc21ef3796c843c137b561c.jpg b/static/uploads/stl/a483b6fdc21ef3796c843c137b561c.jpg new file mode 100644 index 0000000..cfd993e Binary files /dev/null and b/static/uploads/stl/a483b6fdc21ef3796c843c137b561c.jpg differ diff --git a/static/uploads/stl/cbd9ac8333684dea75d102d5ae9a9e.png b/static/uploads/stl/cbd9ac8333684dea75d102d5ae9a9e.png new file mode 100644 index 0000000..a543494 Binary files /dev/null and b/static/uploads/stl/cbd9ac8333684dea75d102d5ae9a9e.png differ diff --git a/static/uploads/stl/cf89b089ff7ccd15a42086824df9ab.jpg b/static/uploads/stl/cf89b089ff7ccd15a42086824df9ab.jpg new file mode 100644 index 0000000..cfd993e Binary files /dev/null and b/static/uploads/stl/cf89b089ff7ccd15a42086824df9ab.jpg differ diff --git a/static/uploads/stl/d38ff410af2bf8f2da14fbc8afc4c9.png b/static/uploads/stl/d38ff410af2bf8f2da14fbc8afc4c9.png new file mode 100644 index 0000000..23695e3 Binary files /dev/null and b/static/uploads/stl/d38ff410af2bf8f2da14fbc8afc4c9.png differ diff --git a/templates/adminpage.html b/templates/adminpage.html index 0e92ddf..4ab5bf0 100644 --- a/templates/adminpage.html +++ b/templates/adminpage.html @@ -8,7 +8,7 @@ - 3d Detals + 3d Detals adminka @@ -20,11 +20,11 @@
- + - + - + diff --git a/templates/index.html b/templates/index.html index 10f1cdb..13829c7 100644 --- a/templates/index.html +++ b/templates/index.html @@ -17,18 +17,19 @@
- {% for i in range(10) %} + {% for key, value in detals.items() %}
- 1 image + +
- + Скачать исходник
- + Скачать stl