ignor und upload flasK
This commit is contained in:
1 parent
294a15cb8e
commit
e9a1261423
8 files changed
+120
-5
No files matched your search
@@ -0,0 +1,39 @@
|
||||
import os
|
||||
from flask import Flask, render_template
|
||||
from dotenv import load_dotenv
|
||||
import csv # CSV handling
|
||||
import random
|
||||
|
||||
|
||||
load_dotenv() # Laden Sie die Umgebungsvariablen aus der .env-Datei
|
||||
|
||||
def load_database():
|
||||
file = os.path.join(os.path.expanduser("~"), "Austausch", "fragen1.csv")
|
||||
|
||||
#with open(file, newline="", encoding="utf-8") as csvfile: #
|
||||
with open(file, newline="", encoding="cp1252") as csvfile: # Code wird als Excel Windows-1252 Input CSV gelesen
|
||||
database = csv.reader(csvfile, delimiter=";") # Validating the "csvfile" into "database" with the delimiter "," (Comma Seperated Values)
|
||||
|
||||
q_a = [] # Empty list for all questions and answers
|
||||
|
||||
for row in database: # alle Zeilen in der Datenbank durchlaufen
|
||||
index = int(row[0]) # Laufende Nummer
|
||||
question = str(row[1]) # Frage (ist der erste Teil)
|
||||
answer = str(row[2]) # Antwort (3. Spalte in der CSV Datenbank)
|
||||
q_a.append({"index": index,"question": question, "answer": answer}) # Eine Liste bauen
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/')
|
||||
#def home():
|
||||
# return 'Willkommen beim Quiz!'
|
||||
#
|
||||
def quiz():
|
||||
# Hier können Sie den HTML-Code für Ihr Quiz-Formular rendern
|
||||
return render_template('quiz.html')
|
||||
|
||||
if __name__ == '__main__':
|
||||
# app.run(debug=True)
|
||||
load_database()
|
||||
port = int(os.getenv("FLASK_RUN_PORT", 5000))
|
||||
app.run(debug=True,host="0.0.0.0", port=port)
|
||||
Reference in new issue
Block a user