use basic auth

This commit is contained in:
dechert
2021-06-21 12:12:44 +02:00
parent 7a5698467f
commit dbe862cf53
5 changed files with 16 additions and 16 deletions

View File

@@ -5,9 +5,8 @@ from flask import render_template
from flask import request, send_from_directory
from flask import url_for
from flask_cors import CORS
# from flask_httpauth import HTTPBasicAuth
# from werkzeug.security import check_password_hash
# import main
from flask_httpauth import HTTPBasicAuth
from werkzeug.security import check_password_hash
from werkzeug.utils import redirect
# import config_parser
@@ -15,21 +14,11 @@ from werkzeug.utils import redirect
import converter
app = Flask(__name__)
# auth = HTTPBasicAuth()
auth = HTTPBasicAuth()
app.config["DEBUG"] = True
CORS(app)
URL_BASE_PATH = "/"
# URL_BASE_PATH = "/tagebuch"
# @auth.verify_password
# def verify_password(username, password):
# if username == config_parser.credentials['username'] and \
# check_password_hash(config_parser.credentials['hashedPassword'], password):
# return username
# OUTPUT_FODLER = "output"
# UPLOAD_FODLER = "upload"
import config_parser
@@ -42,7 +31,15 @@ OUTPUT_FODLER = config_parser.output_path
# return render_template("index.html")
@auth.verify_password
def verify_password(username, password):
if username == config_parser.credentials['username'] and \
check_password_hash(config_parser.credentials['hashedPassword'], password):
return username
@app.route(URL_BASE_PATH, methods=["GET", "POST"])
@auth.login_required
def upload_image():
if request.method == "POST":
if request.files: