erste dinger drin
This commit is contained in:
1 parent
761994967d
commit
5c3ca6099e
3 files changed
+45
-1
No files matched your search
@@ -0,0 +1,2 @@
|
|||||||
|
__pycache__/
|
||||||
|
vokabeln.db
|
||||||
+1
-1
@@ -2,5 +2,5 @@
|
|||||||
#
|
#
|
||||||
# startet den Flask Server in Python
|
# startet den Flask Server in Python
|
||||||
#
|
#
|
||||||
FLASK_APP=gastCheckIn.py FLASK_ENV=production flask run -p 5001
|
FLASK_APP=voctrain.py FLASK_ENV=development flask run -p 5003
|
||||||
|
|
||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
import sqlite3
|
||||||
|
from flask import Flask, render_template, request, url_for, flash, redirect
|
||||||
|
from werkzeug.exceptions import abort
|
||||||
|
|
||||||
|
def get_db_connection():
|
||||||
|
conn = sqlite3.connect('vokabeln.db')
|
||||||
|
conn.row_factory = sqlite3.Row
|
||||||
|
return conn
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
app.config['SECRET_KEY'] = 'ClubhouseHurriedBoxerMosaicUnlawfulWanted'
|
||||||
|
|
||||||
|
@app.route('/', methods=('GET', 'POST'))
|
||||||
|
def index():
|
||||||
|
|
||||||
|
|
||||||
|
if request.method == 'POST':
|
||||||
|
vorname = request.form['vorname']
|
||||||
|
nachname = request.form['nachname']
|
||||||
|
telefonnummer = request.form['telefonnummer']
|
||||||
|
emailadresse = request.form['emailadresse']
|
||||||
|
anschrift = request.form['anschrift']
|
||||||
|
if telefonnummer == '' and emailadresse == '' and anschrift == '':
|
||||||
|
flash('Mindestens eine Eingabe zur Erreichbarkeit muss angegeben werden.','error')
|
||||||
|
else:
|
||||||
|
conn = get_db_connection()
|
||||||
|
conn.execute("INSERT INTO guests ( vorname , nachname, telefonnummer, emailadresse, anschrift) VALUES (?, ?, ?, ?, ?)",
|
||||||
|
(vorname , nachname, telefonnummer, emailadresse, anschrift)
|
||||||
|
)
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
flash('Vielen Dank ' + vorname + ' ' + nachname + ' und viel Freude bei der Veranstaltung!','success')
|
||||||
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
|
|
||||||
|
conn = get_db_connection()
|
||||||
|
guests = conn.execute('SELECT * FROM guests').fetchall()
|
||||||
|
conn.close()
|
||||||
|
return render_template('index.html', guests=guests)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run()
|
||||||
Reference in new issue
Block a user