added admin page

This commit is contained in:
Александр Геннадьевич Сальный
2022-10-17 22:05:57 +03:00
parent 1808c8238f
commit cae7dc1dac
3 changed files with 140 additions and 4 deletions

40
app.py
View File

@@ -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")
app.run(host="0.0.0.0", debug="True", port="3800")

49
static/css/index.css Normal file
View File

@@ -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;
}

55
templates/index.html Normal file
View File

@@ -0,0 +1,55 @@
<!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 rel="stylesheet" href="{{ url_for('static', filename='css/index.css')}}">
<title>3dprintered </title>
</head>
<body>
<h1> Напечатанные детали </h1>
<div class="tableH">
<table class="tg">
<thead>
<tr>
<th class="tg-0lax"></th>
<th class="tg-0lax">Изображения</th>
<th class="tg-0lax"> Напечатано ли</th>
<th class="tg-0lax">STL file</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tg-0lax"></td>
<td class="tg-0lax"></td>
<td class="tg-0lax"></td>
<td class="tg-0lax"></td>
</tr>
<tr>
<td class="tg-0lax"></td>
<td class="tg-0lax"></td>
<td class="tg-0lax"></td>
<td class="tg-0lax"></td>
</tr>
<tr>
<td class="tg-0lax"></td>
<td class="tg-0lax"></td>
<td class="tg-0lax"></td>
<td class="tg-0lax"></td>
</tr>
<tr>
<td class="tg-0lax"></td>
<td class="tg-0lax"></td>
<td class="tg-0lax"></td>
<td class="tg-0lax"></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>