add requirements.txt

This commit is contained in:
2022-11-11 18:48:50 +03:00
parent 207e22d4f6
commit 9d9d68e8d4
5 changed files with 166 additions and 1 deletions

75
app.py
View File

@@ -87,14 +87,87 @@ def upload_file():
stl=stl_file.filename, stl=stl_file.filename,
src=src_file.filename, src=src_file.filename,
isprinted=isprinered, isprinted=isprinered,
dateadd=datetime.now().strftime('%d.%m.%Y')) datead=datetime.now().strftime('%d.%m.%Y'))
db.session.add(detal) db.session.add(detal)
db.session.commit() db.session.commit()
return redirect(url_for('admipage')) return redirect(url_for('admipage'))
@app.route('/editcard')
def editcadrd():
allDetals = {}
detalsQuery = PrintedDetal.query.all()
for detal in detalsQuery:
detals = {}
detals['id'] = detal.id
detals['img'] = detal.img
detals['stl'] = detal.stl
detals['src'] = detal.src
detals['isprinted'] = detal.isprinted
detals['date'] = detal.dateadd
allDetals[detal.id] = detals
return render_template('editcard.html', detals=allDetals)
@app.route('/editcard/<id>')
def editcard2(id):
data = PrintedDetal.query.get(id)
print(data.id)
return render_template('cardupdate.html', data=data.id)
@app.route('/updater', methods=['POST'])
def updater():
if request.method == 'POST':
id = request.form.get('dataid')
detal = PrintedDetal.query.get(id)
image_file = request.files['img']
stl_file = request.files['stl']
src_file = request.files['src']
print(detal.id)
if len(image_file.filename) > 0:
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))
detal.img = 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))
detal.stl = 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))
detal.src = src_file.filename
if request.form.get('isprinted') == 'on':
isprinered = True
else:
isprinered = False
detal.isprinted = isprinered
db.session.commit()
return redirect(url_for('editcadrd'))
return "123"
if __name__ == "__main__": if __name__ == "__main__":

BIN
requirements.txt Normal file

Binary file not shown.

View File

@@ -33,6 +33,10 @@ header {
height: 450px; height: 450px;
} }
.card-edit {
height: 400px;
}
.card-img-top{ .card-img-top{
height: 250px; height: 250px;

40
templates/cardupdate.html Normal file
View File

@@ -0,0 +1,40 @@
<!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 adminka</title>
</head>
<body>
<header>
<h1 class="h1header"> Обновление карточки {{data['id']}}</h1>
</header>
<div class="container">
<div class="row ">
<form method="post" enctype=multipart/form-data action="/updater">
<label class=" d-block p-2">Выберите изображение </label>
<input class=" formblock d-block p-2" type="file" name="img" />
<label class=" d-block p-2">Выберите исходный file </label>
<input class=" formblock d-block p-2" type="file" name="src" />
<label class=" d-block p-2">Выберите stl file </label>
<input class=" formblock d-block p-2" type="file" name="stl" />
<label > Напечатано </label>
<input type="checkbox" class="bxigchekcbox" id="printed" name="isprinted">
<input class="btn d-block p-2" type="submit" value="Обновить">
<input name="dataid" type="hidden" value="{{data}}" >
</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>

48
templates/editcard.html Normal file
View File

@@ -0,0 +1,48 @@
<!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/style.css')}}">
<title>3d Detals</title>
</head>
<body>
<header>
<h1 class="h1header"> Каталог печатных 3д деталей </h1>
</header>
<div class="container">
<div class="row">
{% for key, value in detals.items() %}
<div class="col-md-4">
<div class="card card-edit mobile-margin">
<img class="card-img-top" src="{{url_for('static', filename='uploads/img/' + value['img'])}}">
<div class="card-body">
<dv class="row">
<div class="col">
<a href="/editcard/{{value['id']}}" class="btn btn-block mobile-margin"> Изменить </a>
</div>
<div class="row">
</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>
</body>
</html>