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 0000000..2c17d26 Binary files /dev/null and b/data.db differ diff --git a/templates/index.html b/templates/index.html index 7128314..b66a2a5 100644 --- a/templates/index.html +++ b/templates/index.html @@ -24,7 +24,7 @@
- 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() +