commit a3c3dd0413ace1322e94b3e26d2d80e3eb66908b Author: vitrinekast Date: Fri Dec 27 17:56:43 2024 +0100 setup the project diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b33451a --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +.idea/ +.vscode/ +.venv*/ +venv*/ +__pycache__/ +dist/ +.coverage* +htmlcov/ +.tox/ +docs/_build/ +uploads \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..3da78bf --- /dev/null +++ b/app.py @@ -0,0 +1,54 @@ +import os +from flask import Flask, flash, request, redirect, url_for, render_template, send_from_directory +from werkzeug.utils import secure_filename +import secrets + +UPLOAD_FOLDER = 'uploads' +ALLOWED_EXTENSIONS = {'flac', 'mp3', 'm4a', 'ogg', 'wav'} + +app = Flask(__name__) + +app.secret_key = secrets.token_urlsafe(16) + +app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER + +def allowed_file(filename): + return '.' in filename and \ + filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS + +@app.route("/") +def index(): + upload = request.args.get('upload') + return render_template("index.jinja", status=upload) + +@app.route('/', methods=['POST']) +def upload_file(): + + if request.method == 'POST': + if 'the_voicemail' not in request.files: + flash('No file uploaded', 'form') + return redirect(request.url) + + file = request.files['the_voicemail'] + + if file.filename == '': + flash('No selected file', 'form') + return redirect(request.url) + + if file and allowed_file(file.filename): + filename = secure_filename(file.filename) + path = os.path.join(app.config['UPLOAD_FOLDER'], filename) + file.save(path) + return redirect("?upload=completed") + else: + print(request.method) + return "not a valid thing" + +@app.route('/recent') +def get_most_recent(): + files = os.listdir(app.config["UPLOAD_FOLDER"]) + paths = [os.path.join(app.config["UPLOAD_FOLDER"], basename) for basename in files] + if paths: + return send_from_directory(".", max(paths, key=os.path.getctime)) + else: + return 'file not found', 404 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a667479 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,17 @@ +audioop-lts==0.2.1 +blinker==1.9.0 +certifi==2024.12.14 +charset-normalizer==3.4.1 +click==8.1.8 +docopt==0.6.2 +Flask==3.1.0 +idna==3.10 +itsdangerous==2.2.0 +Jinja2==3.1.5 +MarkupSafe==3.0.2 +pipreqs==0.4.13 +pydub==0.25.1 +requests==2.32.3 +urllib3==2.3.0 +Werkzeug==3.1.3 +yarg==0.1.10 diff --git a/static/style.css b/static/style.css new file mode 100644 index 0000000..75ca4f5 --- /dev/null +++ b/static/style.css @@ -0,0 +1,87 @@ +* { + box-sizing: border-box; +} + +html { + height: 100vh; + position: relative; +} + +body{ + background: url(#background); + background-size: 100% 100%; + -o-background-size: 100% 100%; + -webkit-background-size: 100% 100%; + background-size: cover; + text-align: center; +} + +#app { + margin: 0 auto; + max-width: 620px; + padding-bottom: 30px; +} + +#main { + text-align: center; + height: 4rem; +} + +.border{ + border-color: black; + background-color: white; + border-width: 2px; + border-style: solid; + box-shadow: 5px 5px 5px black; +} + +a { + font-size: 1.8rem; + font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, sans-serif; + color: black; +} + +a:hover { + color: grey; +} + + +p { + font-size: 1.5rem; + padding: 0.5vh 1vw; + font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, sans-serif; +} + + +h1 { + font-size: 3rem; + font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, sans-serif; + font-weight: 600; + text-transform: uppercase; +} + +.home-img{ + width: 620px; + object-fit: cover; +} + +#menu{ + position: fixed; + display: inline-flex; + transform: rotate(-90deg) translate(-100%, 50%); + transform-origin: 0 50%; + left: 10px; + top: 0px; +} + +#menu > p{ + margin: 0px; + margin-left: 10px; +} + +#background{ + position: fixed; + top: 0px; + left: 0px; + z-index: -1; +} diff --git a/templates/index.jinja b/templates/index.jinja new file mode 100644 index 0000000..bcf7981 --- /dev/null +++ b/templates/index.jinja @@ -0,0 +1,73 @@ + + + + + + + + + + Klankschool voicemail + + + + + +
+

VoiceMail

+ +

Heard or made something funky at Klankschool? Leave a voicemail!
Voicemails are archived and can be used by any klankschool member.

+
+

+ {% with messages = get_flashed_messages(category_filter=["form"]) %} + {% if messages %} +

    + {% for message in messages %} +
  • {{ message }}
  • + {% endfor %} +
+ {% endif %} + {% endwith %} + {% if status == "completed" %} +

Wow thank you!

+ {% endif %}
+ + +

+ + + +
+
+ + +