mirror of
https://github.com/Llloooggg/Jarvis.git
synced 2026-03-06 12:06:23 +03:00
Рефракторинг
This commit is contained in:
28
__init__.py
28
__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 = Flask(__name__, static_folder="static", template_folder="templates")
|
||||||
|
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///data.db'
|
||||||
|
db = SQLAlchemy(app)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/', methods=['GET'])
|
@app.route('/', methods=['GET'])
|
||||||
@@ -8,9 +11,26 @@ def index():
|
|||||||
return render_template('index.html')
|
return render_template('index.html')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/login', methods=['GET'])
|
@app.route("/registration", methods=["GET", "POST"])
|
||||||
def login():
|
def register():
|
||||||
return render_template('login.html')
|
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__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
</nav>
|
</nav>
|
||||||
<div class="header_right">
|
<div class="header_right">
|
||||||
<div class="contacts">
|
<div class="contacts">
|
||||||
<a href="/login" class="contacts__schedule">LogIn</a>
|
<a href="/registration" class="contacts__schedule">LogIn</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -48,8 +48,8 @@
|
|||||||
<p class="text_content">Ваш индивидуальный помощник на каждый день</p>
|
<p class="text_content">Ваш индивидуальный помощник на каждый день</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-button">
|
<div class="input-button">
|
||||||
<a href="/login" class="input">
|
<a href="/registration" class="input">
|
||||||
<input type="button" href="/login" name="scriptbutton" class="welcome__btn" value="Авторизоваться" >
|
<input type="button" href="/registration" name="scriptbutton" class="welcome__btn" value="Авторизоваться" >
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
</nav>
|
</nav>
|
||||||
<div class="header_right clearfix">
|
<div class="header_right clearfix">
|
||||||
<label class="form__cell-header ">
|
<label class="form__cell-header ">
|
||||||
<input type="text" class="form__input-text-mod" placeholder="email">
|
<input type="text" class="form__input-text-mod" placeholder="email" >
|
||||||
</label>
|
</label>
|
||||||
<label class="form__cell-header">
|
<label class="form__cell-header">
|
||||||
<input type="text" class="form__input-text-mod" placeholder="password">
|
<input type="text" class="form__input-text-mod" placeholder="password">
|
||||||
@@ -63,7 +63,7 @@
|
|||||||
<div class="form__field-title">
|
<div class="form__field-title">
|
||||||
Введите логин
|
Введите логин
|
||||||
</div>
|
</div>
|
||||||
<input type="text" class="form__input-text" placeholder="Введите login">
|
<input type="text" class="form__input-text" placeholder="Введите login" name = "login">
|
||||||
</label>
|
</label>
|
||||||
<label class="form__log">
|
<label class="form__log">
|
||||||
<div class="form__field-title">
|
<div class="form__field-title">
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
<div class="form__field-title">
|
<div class="form__field-title">
|
||||||
Введите пароль
|
Введите пароль
|
||||||
</div>
|
</div>
|
||||||
<input type="text" class="form__input-text" placeholder="Введите пароль">
|
<input type="text" class="form__input-text" placeholder="Введите пароль" name = "password">
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form__btns">
|
<div class="form__btns">
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form__controls-right">
|
<div class="form__controls-right">
|
||||||
<button type="submit" value="Отправить" class="form__submit">Регистрация</button>
|
<button type="submit" value="Отправить" class="form__submit" >Регистрация</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
17
user_registration.py
Normal file
17
user_registration.py
Normal file
@@ -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()
|
||||||
|
|
||||||
Reference in New Issue
Block a user