Compare commits

..

4 Commits

Author SHA1 Message Date
60f746b2ee add funct 2022-10-29 20:33:12 +03:00
32061c6804 add admin templates 2022-10-25 18:51:11 +03:00
de3d155249 addes redisignered templates 2022-10-24 12:58:14 +03:00
6a01aefc7a added admin page 2022-10-24 12:52:46 +03:00
11 changed files with 131 additions and 57 deletions

34
app.py
View File

@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from turtle import st
from flask import Flask, render_template, request, flash, redirect, url_for
from werkzeug.utils import secure_filename
import os
@@ -26,9 +24,9 @@ db.init_app(app)
@app.route("/")
def index():
detals = PrintedDetal.query.all()
#detals = PrintedDetal.query.all()
return render_template("index.html", detals=detals)
return render_template("index.html") # , detals=detals)
@app.route("/admin", methods=['GET', 'POST'])
@@ -37,37 +35,45 @@ def admipage():
if request.method == 'POST':
logging.debug("POST QUERY loaded")
image_file = request.files['images']
stl_file = request.files['stl']
image_file = request.files['imgfile']
stl_file = request.files['stlfile']
logging.debug(image_file)
logging.debug(stl_file)
image_file.save(os.path.join(app.config['UPLOAD_FOLDER'], image_file.filename))
stl_file.save(os.path.join(app.config['UPLOAD_FOLDER2'], stl_file.filename))
image_file.save(os.path.join(
app.config['UPLOAD_FOLDER'], image_file.filename))
stl_file.save(os.path.join(
app.config['UPLOAD_FOLDER2'], stl_file.filename))
if request.form.get('isprinted') == 'on':
isprinered = True
else:
isprinered = False
detal = PrintedDetal(imgpath=image_file.filename,
stlpath=stl_file.filename,
isprinted=isprinered)
db.session.add(detal)
db.session.commit()
logging.debug(image_file)
logging.debug(stl_file)
logging.debug(isprinered)
# detal = PrintedDetal(imgpath=image_file.filename,
# stlpath=stl_file.filename,
# isprinted=isprinered)
# db.session.add(detal)
# db.session.commit()
return render_template("adminpage.html")
else:
return render_template("adminpage.html")
@app.route('/uploader', methods=['GET', 'POST'])
def upload_file():
if request.method == 'POST':
f = request.files['file']
f.save(secure_filename(f.filename))
return 'file uploaded successfully'
if __name__ == "__main__":
app.run(host="0.0.0.0", debug="True", port="3800")

View File

@@ -8,4 +8,5 @@ class PrintedDetal(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
imgpath = db.Column(db.String(3000))
stlpath = db.Column(db.String(3000))
srcpath = db.Column(db.String(3000))
isprinted = db.Column(db.Boolean())

View File

@@ -37,20 +37,26 @@ input[type="file"]::file-selector-button {
}
input[type="file"]::form-file-button:hover {
input[type="file"]::file-selector-button:hover {
background-color: #fff1b5;
color: #034956;
border: 2px solid #034956;
border: 1px solid #034956;
cursor: pointer;
}
.card {
background-color: #fef6dd;
border-radius: 12px;
box-shadow: 0px 5px 10px 2px rgba(34, 60, 80, 0.2);
}
.btn {
margin-top: 15px;
background-color: #ffe1d0;
color: #034956;
border: 2px solid #f26722;
border-radius: 5px;
width: 100%;
}
@@ -61,3 +67,16 @@ input[type="file"]::form-file-button:hover {
border: 2px solid #034956;
}
.formblock {
width: 100%;
border: 2px solid #034956;
border-radius: 5px;
}
#printed {
width: 20px;
height: 20px;
accent-color: #f26722;
}

View File

@@ -58,3 +58,11 @@ header{
h5{
font-size: 17px;
}
.mobile-margin{
margin-bottom: 10px;
padding: 10px;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 295 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 482 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 585 KiB

39
templates/adminpage.html Normal file
View File

@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
<link rel="stylesheet" href="{{ url_for('static', filename='css/adminpage.css')}}">
<title>3d Detals</title>
</head>
<body>
<header>
<h1 class="h1header"> Административная панель </h1>
</header>
<div class="container">
<div class="row ">
<form method="post" enctype=multipart/form-data>
<label class=" d-block p-2">Выберите изображение </label>
<input class=" formblock d-block p-2" type="file" name="imgfile" />
<label class=" d-block p-2">Выберите исходный file </label>
<input class=" formblock d-block p-2" type="file" name="origfile" />
<label class=" d-block p-2">Выберите stl file </label>
<input class=" formblock d-block p-2" type="file" name="stlfile" />
<label > Напечатано </label>
<input type="checkbox" class="bxigchekcbox" id="printed" name="isprinted">
<input class="btn d-block p-2" type="submit" value="Upload">
</form>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3"
crossorigin="anonymous"></script>
</body>
</html>

View File

@@ -19,38 +19,39 @@
{% for i in range(10) %}
<div class="col-md-4">
<div class="card">
<img class="card-img-top" src="{{ url_for('static', filename='img/{{i}}.jpg')}} " alt="1 image">
<div class="card mobile-margin">
<img class="card-img-top" src="{{url_for('static', filename='img/1.jpg')}}" alt="1 image">
<div class="card-body">
<dv class="row">
<div class="col">
<button class="btn btn-block">Скачать исходник</button>
<button class="btn btn-block mobile-margin">Скачать исходник</button>
</div>
<div class="col">
<button class="btn btn-block">Скачать stl </button>
<button class="btn btn-block mobile-margin">Скачать stl </button>
</div>
<div class="row">
<div class="col d-flex justify-content-center">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault" disabled>
<label class="form-check-label" for="flexCheckDefault">
Напечатано
</label>
</div>
<div class="col d-flex justify-content-center">
<h5> {{ i }} </h5>
<h5> 22.10.2022</h5>
</div>
</div>
</div>
</div>
</div>
{%endfor%}
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3"
crossorigin="anonymous"></script>