From 4f3ff6676017568533d66dab37d64156b1590860 Mon Sep 17 00:00:00 2001 From: burzuf Date: Fri, 13 Mar 2020 23:02:18 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D1=80=D0=B0=D0=BA=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=BD=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __init__.py | 28 +- data.db | Bin 0 -> 12288 bytes templates/index.html | 6 +- templates/{login.html => registration.html} | 308 ++++++++++---------- user_registration.py | 17 ++ 5 files changed, 198 insertions(+), 161 deletions(-) create mode 100644 data.db rename templates/{login.html => registration.html} (95%) create mode 100644 user_registration.py diff --git a/__init__.py b/__init__.py index 9194866..0fdbfa6 100644 --- a/__init__.py +++ b/__init__.py @@ -1,6 +1,9 @@ -from flask import Flask, render_template +from flask import Flask, render_template, flash, redirect, url_for, session, logging, request +from flask_sqlalchemy import SQLAlchemy app = Flask(__name__, static_folder="static", template_folder="templates") +app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///data.db' +db = SQLAlchemy(app) @app.route('/', methods=['GET']) @@ -8,9 +11,26 @@ def index(): return render_template('index.html') -@app.route('/login', methods=['GET']) -def login(): - return render_template('login.html') +@app.route("/registration", methods=["GET", "POST"]) +def register(): + if request.method == "POST": + + UserLogin = request.form['login'] + UserPass = request.form['password'] + + #db.session.add(UserLogin, UserPass) + #db.session.commit() + + #return redirect(url_for("")) + + print(UserLogin, ' ', UserPass) + + return render_template("registration.html") + + +# @app.route('/login', methods=['GET']) +# def login(): +# return render_template('login.html') if __name__ == "__main__": diff --git a/data.db b/data.db new file mode 100644 index 0000000000000000000000000000000000000000..2c17d263307e550f58f2023da110417fd4cb3577 GIT binary patch literal 12288 zcmeI#&r8EF6bJB^Oq3SJyyY5tT0sQyD56z^6l>jT3hq=Yc2bxtE)~4$pW%Pze`6Xf zh#&~Njc*{y%MTvplheDMCUslMd9!*dTX{&k#2B4QNkrWCf$e?k;;nvRXZ9ohE9A6) z@;S7pd~`&kxgF3T009U<00Izz00bZa0SG_<0_zKWte@iF8A84-js>H7`B1%@=Y_4K zi}Iyy+`7n3wKBzln+9)!?Fb>*`>-wV7nR#|13%AHq?OdsS)yd%_5wNfJr~9offuJ* zU8-#Fdn;)k>t*0+b*E)|V|$(?GEd`auKFvJ(wJX2?9n8PucK@xuheYZClCFwtIciE zj|Kq
- LogIn + LogIn
@@ -48,8 +48,8 @@

Ваш индивидуальный помощник на каждый день

diff --git a/templates/login.html b/templates/registration.html similarity index 95% rename from templates/login.html rename to templates/registration.html index 841ee4d..10e89c6 100644 --- a/templates/login.html +++ b/templates/registration.html @@ -1,155 +1,155 @@ - - - - - - - jarvis - - - - -
- -
-
- - - - - -
- - - - - -
-
-
- - - -
-
- Создать аккаунт -
- -
-
-
- - - - - -
-
-
-
-
-

- Пол -

-
- - -
-
-
- -
-
-
-
- -
-
-
-
- - -
-
- - - -
-
- + + + + + + + jarvis + + + + +
+ +
+
+ + + + + +
+ + + + + +
+
+
+ + + +
+
+ Создать аккаунт +
+ +
+
+
+ + + + + +
+
+
+
+
+

+ Пол +

+
+ + +
+
+
+ +
+
+
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/user_registration.py b/user_registration.py new file mode 100644 index 0000000..2ee0af4 --- /dev/null +++ b/user_registration.py @@ -0,0 +1,17 @@ +import sqlite3 as sql +import json + + +db = "data.db" + +with open("pkg.json") as req: + json.dump(data, write_file) + + +def add_user(login, hash_password): + con = sql.connect(db) + cur = con.cursor() + cur.execute("INSERT INTO Users (UserLogin , UserPass) VALUES (?,?)", (login, hash_password)) + con.commit() + con.close() +