Skip to content

Commit

Permalink
opravy
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Vybíhal committed Dec 1, 2022
1 parent bfa6f38 commit a451e8b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
Binary file added data.db
Binary file not shown.
1 change: 1 addition & 0 deletions data.db.sqbpro
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><sqlb_project><db path="/home/[email protected]/prvni-flask-Felipsek/data.db" readonly="0" foreign_keys="1" case_sensitive_like="0" temp_store="0" wal_autocheckpoint="1000" synchronous="2"/><attached/><window><main_tabs open="structure browser pragmas query" current="0"/></window><tab_structure><column_width id="0" width="300"/><column_width id="1" width="0"/><column_width id="2" width="100"/><column_width id="3" width="912"/><column_width id="4" width="0"/><expanded_item id="0" parent="1"/><expanded_item id="1" parent="1"/><expanded_item id="2" parent="1"/><expanded_item id="3" parent="1"/></tab_structure><tab_browse><current_table name="4,4:mainuser"/><default_encoding codec=""/><browse_table_settings><table schema="main" name="user" show_row_id="0" encoding="" plot_x_axis="" unlock_view_pk="_rowid_"><sort><column index="1" mode="0"/></sort><column_widths><column index="1" value="307"/><column index="2" value="268"/></column_widths><filter_values/><conditional_formats/><row_id_formats/><display_formats/><hidden_columns/><plot_y_axes/><global_filter/></table></browse_table_settings></tab_browse><tab_sql><sql name="SQL 1"></sql><current_tab id="0"/></tab_sql></sqlb_project>
13 changes: 13 additions & 0 deletions mysqlite.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import sqlite3


class SQLite():
def __init__(self, file='db.sqlite3'):
self.file=file
def __enter__(self):
self.conn = sqlite3.connect(self.file)
self.conn.row_factory = sqlite3.Row
return self.conn.cursor()
def __exit__(self, type, value, traceback):
self.conn.commit()
self.conn.close()
12 changes: 10 additions & 2 deletions webface.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from decimal import DivisionByZero
from flask import Flask, render_template, request, redirect, url_for, session, flash
import functools

from mysqlite import SQLite
# from werkzeug.security import generate_password_hash, check_password_hash

app = Flask(__name__)
Expand All @@ -12,6 +12,8 @@
slova = ("Super", "Perfekt", "Úža", "Flask")




def prihlasit(function):
@functools.wraps(function)
def wrapper(*args, **kwargs):
Expand Down Expand Up @@ -78,7 +80,13 @@ def login_post():
jmeno = request.form.get('jmeno')
heslo = request.form.get('heslo')
page = request.args.get("page")
if jmeno == "marek" and heslo == "lokomotiva":

with SQLite("data.db") as cur:
cur.execute("SELECT passwd FROM user WHERE login = ? ", [jmeno] )
ans = cur.fetchall()


if ans and ans[0][0]== heslo:
flash("jsi přihlašen", "message")
session["uzivatel"] = jmeno
if page:
Expand Down

0 comments on commit a451e8b

Please sign in to comment.