add upload admins form

This commit is contained in:
tets@test.test
2022-10-24 01:16:52 +03:00
parent 65a52fe64c
commit 46a604054c
3 changed files with 61 additions and 99 deletions

16
app.py
View File

@@ -26,8 +26,6 @@ db.init_app(app)
@app.route("/")
def index():
print(app.config['UPLOAD_FOLDER2'])
print(type(app.config['UPLOAD_FOLDER']))
detals = PrintedDetal.query.all()
return render_template("index.html", detals=detals)
@@ -35,11 +33,16 @@ def index():
@app.route("/admin", methods=['GET', 'POST'])
def admipage():
logging.debug("adminpage loaded")
if request.method == 'POST':
logging.debug("POST QUERY loaded")
image_file = request.files['images']
stl_file = request.files['stl']
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))
@@ -60,6 +63,11 @@ def admipage():
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")