From cae7dc1dac57afc7bd3c6552acfe6e040dc6c2d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=93=D0=B5=D0=BD=D0=BD=D0=B0=D0=B4=D1=8C=D0=B5=D0=B2=D0=B8?= =?UTF-8?q?=D1=87=20=D0=A1=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9?= Date: Mon, 17 Oct 2022 22:05:57 +0300 Subject: [PATCH] added admin page --- app.py | 40 ++++++++++++++++++++++++++++---- static/css/index.css | 49 +++++++++++++++++++++++++++++++++++++++ templates/index.html | 55 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+), 4 deletions(-) create mode 100644 static/css/index.css create mode 100644 templates/index.html diff --git a/app.py b/app.py index 564e3dd..d7070c1 100644 --- a/app.py +++ b/app.py @@ -1,21 +1,53 @@ -from flask import Flask, render_template +from turtle import st +from flask import Flask, render_template, request, flash, redirect, url_for +from werkzeug.utils import secure_filename +import os from models import db +from models import PrintedDetal - +UPLOAD_FOLDER = 'uploads' +ALLOWED_EXTENSIONS = {'txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'} app = Flask(__name__) -app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////app.db' +app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///app.db' +app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER + db.init_app(app) +def allowed_file(filename): + return '.' in filename and \ + filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS + + @app.route("/") def index(): + detals = PrintedDetal.query.all() + print(detals[0].imgpath) return render_template("index.html") +@app.route("/admin", methods=['GET', 'POST']) +def admipage(): + if request.method == 'POST': + image_file = request.files['images'] + stl_file = request.files['stl'] + + filename = secure_filename(image_file.filename) + image_file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) + print(filename) + + filename = secure_filename(stl_file.filename) + stl_file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) + print(filename) + + return render_template("adminpage.html") + + else: + return render_template("adminpage.html") if __name__ == "__main__": - app.run(host="0.0.0.0", debug="True", port="3800") \ No newline at end of file + app.run(host="0.0.0.0", debug="True", port="3800") diff --git a/static/css/index.css b/static/css/index.css new file mode 100644 index 0000000..2d981c0 --- /dev/null +++ b/static/css/index.css @@ -0,0 +1,49 @@ +body{ + background-color: rgb(166, 253, 254); + +} +h1{ + text-align: center; +} +.tableH{ + + background-color: antiquewhite; +} +.tg { + border-collapse: collapse; + border-spacing: 0; + align-self: center; + width: 100%; +} + +.tg td { + border-color: black; + border-style: solid; + border-width: 1px; + font-family: Arial, sans-serif; + font-size: 14px; + overflow: hidden; + padding: 10px 5px; + word-break: normal; +} + +.tg th { + border-color: black; + border-style: solid; + border-width: 1px; + font-family: Arial, sans-serif; + font-size: 14px; + font-weight: normal; + overflow: hidden; + padding: 10px 5px; + word-break: normal; + +} + +.tg .tg-0lax { + text-align: center; + vertical-align: top; + border-radius: 100px; + border-radius: 100px; + +} \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..886f770 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,55 @@ + + + + + + + + + 3dprintered + + + +

Напечатанные детали

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Изображения Напечатано лиSTL file
+
+ + + \ No newline at end of file