From 8f3427c46804215f5288922a0291be414e955925 Mon Sep 17 00:00:00 2001 From: TD589 Date: Sat, 29 Mar 2025 17:23:45 +0100 Subject: [PATCH] =?UTF-8?q?test-area=20erg=C3=A4nzt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fomular_bsp/app.py | 18 ++++ fomular_bsp/explain.txt | 84 ++++++++++++++++++ fomular_bsp/templates/contact.html | 20 +++++ fomular_bsp/templates/index.html | 11 +++ fomular_bsp/templates/thankyou.html | 11 +++ fomular_bsp_email/app.py | 40 +++++++++ fomular_bsp_email/explain.txt | 84 ++++++++++++++++++ fomular_bsp_email/templates/contact.html | 20 +++++ fomular_bsp_email/templates/index.html | 11 +++ fomular_bsp_email/templates/thankyou.html | 11 +++ test1/app.py | 9 ++ test1/static/style.css | 24 +++++ test1/templates/index.html | 32 +++++++ würfel/__pycache__/simulation.cpython-311.pyc | Bin 0 -> 385 bytes würfel/app.py | 14 +++ würfel/simulation.py | 3 + würfel/templates/index.html | 11 +++ 17 files changed, 403 insertions(+) create mode 100644 fomular_bsp/app.py create mode 100644 fomular_bsp/explain.txt create mode 100644 fomular_bsp/templates/contact.html create mode 100644 fomular_bsp/templates/index.html create mode 100644 fomular_bsp/templates/thankyou.html create mode 100644 fomular_bsp_email/app.py create mode 100644 fomular_bsp_email/explain.txt create mode 100644 fomular_bsp_email/templates/contact.html create mode 100644 fomular_bsp_email/templates/index.html create mode 100644 fomular_bsp_email/templates/thankyou.html create mode 100644 test1/app.py create mode 100644 test1/static/style.css create mode 100644 test1/templates/index.html create mode 100644 würfel/__pycache__/simulation.cpython-311.pyc create mode 100644 würfel/app.py create mode 100644 würfel/simulation.py create mode 100644 würfel/templates/index.html diff --git a/fomular_bsp/app.py b/fomular_bsp/app.py new file mode 100644 index 0000000..76485aa --- /dev/null +++ b/fomular_bsp/app.py @@ -0,0 +1,18 @@ +from flask import Flask, render_template, request, redirect, url_for + +app = Flask(__name__) + +@app.route('/') +def home(): + return render_template('index.html') + +@app.route('/kontakt', methods=['GET', 'POST']) +def kontakt(): + if request.method == 'POST': + name = request.form['name'] + nachricht = request.form['nachricht'] + return render_template('thankyou.html', name=name) + return render_template('contact.html') + +if __name__ == '__main__': + app.run(debug=True, port=5000) diff --git a/fomular_bsp/explain.txt b/fomular_bsp/explain.txt new file mode 100644 index 0000000..cdf93fe --- /dev/null +++ b/fomular_bsp/explain.txt @@ -0,0 +1,84 @@ +from flask import Flask, render_template, request, redirect, url_for +👉 Wir importieren Funktionen aus dem Flask-Framework: + +Flask: Hauptklasse, um unsere Web-App zu erstellen + +render_template: zeigt HTML-Dateien an + +request: ermöglicht Zugriff auf Formulardaten + +redirect & url_for: nützlich für Weiterleitungen (werden hier zwar nicht benutzt, aber vorbereitet) + + +app = Flask(__name__) +👉 Wir erstellen eine Instanz der Flask-App, sie heißt hier einfach app. +__name__ sagt Flask, wo sich das aktuelle Skript befindet. Das ist nötig für Routing, Templating etc. + + +@app.route('/') +def home(): + return render_template('index.html') +🟢 Route 1 – Startseite (/): + +@app.route('/'): Flask soll diese Funktion ausführen, wenn jemand die Startseite aufruft (z. B. http://localhost:5000/) + +render_template('index.html'): zeigt die HTML-Datei templates/index.html im Browser + + +@app.route('/kontakt', methods=['GET', 'POST']) +def kontakt(): +🟢 Route 2 – Kontaktformular (/kontakt): + +Diese Funktion verarbeitet zwei HTTP-Methoden: + +GET: Zeigt das Formular an + +POST: Verarbeitet die abgeschickten Formulardaten + + + if request.method == 'POST': +👉 Prüft, ob das Formular abgeschickt wurde (per POST) + + + name = request.form['name'] + nachricht = request.form['nachricht'] +👉 Holt sich die Formulardaten: + +name: aus dem + +nachricht: aus dem +

+ + + Zurück zur Startseite + + diff --git a/fomular_bsp/templates/index.html b/fomular_bsp/templates/index.html new file mode 100644 index 0000000..ec19fec --- /dev/null +++ b/fomular_bsp/templates/index.html @@ -0,0 +1,11 @@ + + + + + Startseite + + +

Willkommen auf unserer Mini-Seite

+ Zum Kontaktformular + + diff --git a/fomular_bsp/templates/thankyou.html b/fomular_bsp/templates/thankyou.html new file mode 100644 index 0000000..597fbbe --- /dev/null +++ b/fomular_bsp/templates/thankyou.html @@ -0,0 +1,11 @@ + + + + + Danke! + + +

Danke für deine Nachricht, {{ name }}!

+ Zurück zur Startseite + + diff --git a/fomular_bsp_email/app.py b/fomular_bsp_email/app.py new file mode 100644 index 0000000..0a5f8b4 --- /dev/null +++ b/fomular_bsp_email/app.py @@ -0,0 +1,40 @@ +from flask import Flask, request, render_template +import smtplib +from email.message import EmailMessage + +app = Flask(__name__)# + +@app.route('/') +def home(): + return render_template('index.html') + +@app.route('/kontakt', methods=['GET', 'POST']) +def kontakt(): + if request.method == 'POST': + name = request.form['name'] + nachricht = request.form['nachricht'] + + # ✉️ E-Mail vorbereiten + empfaenger = "tdpain5@gmail.com" + absender = "noreply@example.com" + passwort = "DEIN_APP_PASSWORT" + + msg = EmailMessage() + msg['Subject'] = f"Neue Nachricht von {name}" + msg['From'] = absender + msg['To'] = empfaenger + msg.set_content(nachricht) + + # 📤 E-Mail senden + try: + with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp: + smtp.login(absender, passwort) + smtp.send_message(msg) + return "E-Mail erfolgreich gesendet!" + except Exception as e: + return f"Fehler beim Senden: {e}" + + return render_template('contact.html') + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=5000, debug=True) \ No newline at end of file diff --git a/fomular_bsp_email/explain.txt b/fomular_bsp_email/explain.txt new file mode 100644 index 0000000..cdf93fe --- /dev/null +++ b/fomular_bsp_email/explain.txt @@ -0,0 +1,84 @@ +from flask import Flask, render_template, request, redirect, url_for +👉 Wir importieren Funktionen aus dem Flask-Framework: + +Flask: Hauptklasse, um unsere Web-App zu erstellen + +render_template: zeigt HTML-Dateien an + +request: ermöglicht Zugriff auf Formulardaten + +redirect & url_for: nützlich für Weiterleitungen (werden hier zwar nicht benutzt, aber vorbereitet) + + +app = Flask(__name__) +👉 Wir erstellen eine Instanz der Flask-App, sie heißt hier einfach app. +__name__ sagt Flask, wo sich das aktuelle Skript befindet. Das ist nötig für Routing, Templating etc. + + +@app.route('/') +def home(): + return render_template('index.html') +🟢 Route 1 – Startseite (/): + +@app.route('/'): Flask soll diese Funktion ausführen, wenn jemand die Startseite aufruft (z. B. http://localhost:5000/) + +render_template('index.html'): zeigt die HTML-Datei templates/index.html im Browser + + +@app.route('/kontakt', methods=['GET', 'POST']) +def kontakt(): +🟢 Route 2 – Kontaktformular (/kontakt): + +Diese Funktion verarbeitet zwei HTTP-Methoden: + +GET: Zeigt das Formular an + +POST: Verarbeitet die abgeschickten Formulardaten + + + if request.method == 'POST': +👉 Prüft, ob das Formular abgeschickt wurde (per POST) + + + name = request.form['name'] + nachricht = request.form['nachricht'] +👉 Holt sich die Formulardaten: + +name: aus dem + +nachricht: aus dem +
+ + + Zurück zur Startseite + + diff --git a/fomular_bsp_email/templates/index.html b/fomular_bsp_email/templates/index.html new file mode 100644 index 0000000..ec19fec --- /dev/null +++ b/fomular_bsp_email/templates/index.html @@ -0,0 +1,11 @@ + + + + + Startseite + + +

Willkommen auf unserer Mini-Seite

+ Zum Kontaktformular + + diff --git a/fomular_bsp_email/templates/thankyou.html b/fomular_bsp_email/templates/thankyou.html new file mode 100644 index 0000000..597fbbe --- /dev/null +++ b/fomular_bsp_email/templates/thankyou.html @@ -0,0 +1,11 @@ + + + + + Danke! + + +

Danke für deine Nachricht, {{ name }}!

+ Zurück zur Startseite + + diff --git a/test1/app.py b/test1/app.py new file mode 100644 index 0000000..4352409 --- /dev/null +++ b/test1/app.py @@ -0,0 +1,9 @@ +from flask import Flask, render_template + +app = Flask(__name__) + +@app.route('/', methods=['GET']) +def home(): + return render_template('index.html') + +app.run(host='0.0.0.0', port=5000, debug=True) diff --git a/test1/static/style.css b/test1/static/style.css new file mode 100644 index 0000000..4333ee6 --- /dev/null +++ b/test1/static/style.css @@ -0,0 +1,24 @@ +h1 { + color: rgb(22, 156, 145); +} + +progress { + width: 100%; + height: 20px; + background-color: #f3f3f3; + border-radius: 5px; + overflow: hidden; +} + +header { + background-color: grey ; + opacity:0.75; + padding: 20px; + text-align: center; + border-bottom: 10px solid #c50909; + +} + +body{ + background-color:khaki; +} \ No newline at end of file diff --git a/test1/templates/index.html b/test1/templates/index.html new file mode 100644 index 0000000..13dc4e4 --- /dev/null +++ b/test1/templates/index.html @@ -0,0 +1,32 @@ + + + + + + Testseite + + + +
+ +
+

Willkommen auf unserer Testseite

+

Auf dieser Website machen wir viel Quatsch und Blödsinn zum testen.

+

Fortschritt der Website

+

+ + + + diff --git a/würfel/__pycache__/simulation.cpython-311.pyc b/würfel/__pycache__/simulation.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..64df7fb940c2b8daf6dc184397c19347ead4c491 GIT binary patch literal 385 zcmZ3^%ge<81T1VX(!GK7V-N=h7@>^MJV3^Dh7^VthA4&<#$X0brev5J5X}O_%s~8E z4M+ghF{Uu(Fyu1UGB7eQG1M@mFsHCAV`5-f4a5)tG=bIcC5XL}@fLegVqQvSUdc<4 zbuZa~geKE1HjrR`ZV@YxTLdz{7$mFk)e1;DTg8MHrxq2*lq8jwq{g^=hQzz&7p13W z<;Rqy7MH{)7NsV}lpo$xl$M$kQ=FMwnv+ + + + + Würfelspiel + + +

Du hast eine {{ zahl }} gewürfelt!

+ Nochmal würfeln + +