Skip to content

Commit 27ab8af

Browse files
src
1 parent 87ba683 commit 27ab8af

22 files changed

Lines changed: 337 additions & 0 deletions
12 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- database: ./database.db
2+
3+
CREATE TABLE TLD91_USERS (
4+
email text PRIMARY KEY NOT NULL,
5+
password INTEGER NOT NULL
6+
);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from flask import current_app
2+
import sqlite3 as sql
3+
4+
5+
# Code snippet for logging a message
6+
# current_app.logger.critical("message")
7+
8+
9+
def check_login(email, password):
10+
con = sql.connect("database_files/database.db")
11+
cur = con.cursor()
12+
cur.execute(
13+
"SELECT * FROM TLD91_USERS WHERE email == ? AND password == ?",
14+
(email, password),
15+
)
16+
result = cur.fetchone()
17+
con.close()
18+
if result is None:
19+
return False
20+
else:
21+
return True

_source/Basic_Flask_PWA/main.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from flask import Flask
2+
from flask import render_template
3+
from flask import request
4+
import db_interface as db_manager
5+
6+
app = Flask(__name__)
7+
8+
is_logged_in = False
9+
10+
11+
@app.route("/", methods=["POST", "GET"])
12+
def index_page():
13+
global is_logged_in
14+
if request.method == "POST":
15+
if request.form["password"].isdigit():
16+
password = int(request.form["password"])
17+
email = request.form["email"]
18+
is_logged_in = db_manager.check_login(email, password)
19+
app.logger.critical(f"{email} is logged in ? {is_logged_in}")
20+
return render_template("index.html", is_logged_in=is_logged_in), 200
21+
22+
23+
if __name__ == "__main__":
24+
app.run(debug=True)

_source/Basic_Flask_PWA/static/css/bootstrap.min.css

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
* {
2+
3+
}
4+
body {
5+
6+
}
7+
.container {
8+
9+
}
10+
11+
.row {
12+
13+
}
9.66 KB
Loading
1.61 KB
Loading
2 KB
Loading
2.52 KB
Loading

0 commit comments

Comments
 (0)