added admin page
This commit is contained in:
38
app.py
38
app.py
@@ -1,20 +1,52 @@
|
|||||||
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 db
|
||||||
|
from models import PrintedDetal
|
||||||
|
|
||||||
|
|
||||||
|
UPLOAD_FOLDER = 'uploads'
|
||||||
|
ALLOWED_EXTENSIONS = {'txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'}
|
||||||
|
|
||||||
app = Flask(__name__)
|
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)
|
db.init_app(app)
|
||||||
|
|
||||||
|
|
||||||
|
def allowed_file(filename):
|
||||||
|
return '.' in filename and \
|
||||||
|
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
||||||
|
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
|
detals = PrintedDetal.query.all()
|
||||||
|
print(detals[0].imgpath)
|
||||||
return render_template("index.html")
|
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__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
49
static/css/index.css
Normal file
49
static/css/index.css
Normal 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
55
templates/index.html
Normal 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>
|
||||||
Reference in New Issue
Block a user