mirror of
https://github.com/Llloooggg/Jarvis.git
synced 2026-03-06 03:56: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.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__":
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
</nav>
|
||||
<div class="header_right">
|
||||
<div class="contacts">
|
||||
<a href="/login" class="contacts__schedule">LogIn</a>
|
||||
<a href="/registration" class="contacts__schedule">LogIn</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -48,8 +48,8 @@
|
||||
<p class="text_content">Ваш индивидуальный помощник на каждый день</p>
|
||||
</div>
|
||||
<div class="input-button">
|
||||
<a href="/login" class="input">
|
||||
<input type="button" href="/login" name="scriptbutton" class="welcome__btn" value="Авторизоваться" >
|
||||
<a href="/registration" class="input">
|
||||
<input type="button" href="/registration" name="scriptbutton" class="welcome__btn" value="Авторизоваться" >
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
</nav>
|
||||
<div class="header_right clearfix">
|
||||
<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 class="form__cell-header">
|
||||
<input type="text" class="form__input-text-mod" placeholder="password">
|
||||
@@ -63,7 +63,7 @@
|
||||
<div class="form__field-title">
|
||||
Введите логин
|
||||
</div>
|
||||
<input type="text" class="form__input-text" placeholder="Введите login">
|
||||
<input type="text" class="form__input-text" placeholder="Введите login" name = "login">
|
||||
</label>
|
||||
<label class="form__log">
|
||||
<div class="form__field-title">
|
||||
@@ -75,7 +75,7 @@
|
||||
<div class="form__field-title">
|
||||
Введите пароль
|
||||
</div>
|
||||
<input type="text" class="form__input-text" placeholder="Введите пароль">
|
||||
<input type="text" class="form__input-text" placeholder="Введите пароль" name = "password">
|
||||
</label>
|
||||
</div>
|
||||
<div class="form__btns">
|
||||
@@ -99,7 +99,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form__controls-right">
|
||||
<button type="submit" value="Отправить" class="form__submit">Регистрация</button>
|
||||
<button type="submit" value="Отправить" class="form__submit" >Регистрация</button>
|
||||
</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