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>
|
||||
|
||||
@@ -1,155 +1,155 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru-RU">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>jarvis</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename = './css/main.css') }}">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<!-- header -->
|
||||
<header class="header">
|
||||
<div class="container clearfix">
|
||||
<div class="header_left clearfix">
|
||||
<a href="/" class="logo-decor">
|
||||
<img class="logo_icon" src="img/815a836e51c6f20226cb07df7f32895c.png" alt="">
|
||||
<p class="logo-text">J.a.r.v.i.s </p>
|
||||
</a>
|
||||
</div>
|
||||
<!-- menu -->
|
||||
|
||||
|
||||
</nav>
|
||||
<div class="header_right clearfix">
|
||||
<label class="form__cell-header ">
|
||||
<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">
|
||||
</label>
|
||||
<a href="" class="input">
|
||||
<input type="button" href="/comments.html" name="scriptbutton" class="header_btn" value="Войти" >
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
<section class="form">
|
||||
<div class="form__title">
|
||||
Создать аккаунт
|
||||
</div>
|
||||
<!-- лейблы -->
|
||||
<div class="form__fields">
|
||||
<div class="form__element" method="post">
|
||||
<div class="form__row clearfix">
|
||||
<label class="form__cell">
|
||||
<div class="form__field-title">
|
||||
Ваше имя
|
||||
</div>
|
||||
<input type="text" class="form__input-text" placeholder="Введите имя">
|
||||
</label>
|
||||
<label class="form__cell">
|
||||
<div class="form__field-title">
|
||||
Ваша фамилия
|
||||
</div>
|
||||
<input type="text" class="form__input-text" placeholder="Введите фамилию">
|
||||
</label>
|
||||
<label class="form__log">
|
||||
<div class="form__field-title">
|
||||
Введите логин
|
||||
</div>
|
||||
<input type="text" class="form__input-text" placeholder="Введите login">
|
||||
</label>
|
||||
<label class="form__log">
|
||||
<div class="form__field-title">
|
||||
Введите email
|
||||
</div>
|
||||
<input type="text" class="form__input-text" placeholder="Введите email">
|
||||
</label>
|
||||
<label class="form__log">
|
||||
<div class="form__field-title">
|
||||
Введите пароль
|
||||
</div>
|
||||
<input type="text" class="form__input-text" placeholder="Введите пароль">
|
||||
</label>
|
||||
</div>
|
||||
<div class="form__btns">
|
||||
<div class="form__controls">
|
||||
<div class="form__controls-btns clearfix">
|
||||
<div class="form__container-left">
|
||||
<p class="form__field-title">
|
||||
Пол
|
||||
</p>
|
||||
<div class="form__controls-left">
|
||||
<label class="form__radio">
|
||||
<input type="radio" name="review" class="form__radio-elem" checked>
|
||||
<div class="form__radio-fake"></div>
|
||||
<div class="form__radio-text">Муж.</div>
|
||||
</label>
|
||||
<label class="form__radio">
|
||||
<input type="radio" name="review" class="form__radio-elem" >
|
||||
<div class="form__radio-fake"></div>
|
||||
<div class="form__radio-text ">Жен.</div>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form__controls-right">
|
||||
<button type="submit" value="Отправить" class="form__submit">Регистрация</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<!-- заглушка -->
|
||||
<footer class="footer clearfix">
|
||||
<div class="container">
|
||||
<div class="footer-q clearfix">
|
||||
<p class="footer-full-text">Сделано с любовью и старанием на курсе ВГУ "Тестирование ПО" <br> Автор работы: <b class="footer-text_name">Трухачев Сергей</b> </p>
|
||||
</div>
|
||||
<div class="footer-q clearfix">
|
||||
<a href="/" class="logo-text">j.a.r.v.i.s</a>
|
||||
</div>
|
||||
<div class="footer-q clearfix">
|
||||
<p class="footer-messeger_text">Наши социальные сети</p>
|
||||
<ul class="footer-messeger">
|
||||
<li class="footer-messeger__item ">
|
||||
<a href="" class="footer-messeger__link">
|
||||
<img src="{{ url_for('static', filename='./img/afrodita/vk.png') }}" class="footer-messeger__icon" alt="">
|
||||
</a>
|
||||
</li>
|
||||
<li class="footer-messeger__item">
|
||||
<a href="" class="footer-messeger__link ">
|
||||
<img src="{{ url_for('static', filename='./img/afrodita/fb.png') }}" class="footer-messeger__icon" alt="">
|
||||
</a>
|
||||
</li>
|
||||
<li class="footer-messeger__item">
|
||||
<a href="" class="footer-messeger__link">
|
||||
<img src="{{ url_for('static', filename='./img/afrodita/google.png') }}" class="footer-messeger__icon" alt="">
|
||||
</a>
|
||||
</li>
|
||||
<li class="footer-messeger__item">
|
||||
<a href="" class="footer-messeger__link">
|
||||
<img src="{{ url_for('static', filename='./img/afrodita/twitter.png') }}" class="footer-messeger__icon" alt="">
|
||||
</a>
|
||||
</li>
|
||||
<li class="footer-messeger__item">
|
||||
<a href="" class="footer-messeger__link">
|
||||
<img src="{{ url_for('static', filename='./img/afrodita/mail.png') }}" class="footer-messeger__icon" alt="">
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru-RU">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>jarvis</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename = './css/main.css') }}">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<!-- header -->
|
||||
<header class="header">
|
||||
<div class="container clearfix">
|
||||
<div class="header_left clearfix">
|
||||
<a href="/" class="logo-decor">
|
||||
<img class="logo_icon" src="img/815a836e51c6f20226cb07df7f32895c.png" alt="">
|
||||
<p class="logo-text">J.a.r.v.i.s </p>
|
||||
</a>
|
||||
</div>
|
||||
<!-- menu -->
|
||||
|
||||
|
||||
</nav>
|
||||
<div class="header_right clearfix">
|
||||
<label class="form__cell-header ">
|
||||
<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">
|
||||
</label>
|
||||
<a href="" class="input">
|
||||
<input type="button" href="/comments.html" name="scriptbutton" class="header_btn" value="Войти" >
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
<section class="form">
|
||||
<div class="form__title">
|
||||
Создать аккаунт
|
||||
</div>
|
||||
<!-- лейблы -->
|
||||
<div class="form__fields">
|
||||
<div class="form__element" method="post">
|
||||
<div class="form__row clearfix">
|
||||
<label class="form__cell">
|
||||
<div class="form__field-title">
|
||||
Ваше имя
|
||||
</div>
|
||||
<input type="text" class="form__input-text" placeholder="Введите имя">
|
||||
</label>
|
||||
<label class="form__cell">
|
||||
<div class="form__field-title">
|
||||
Ваша фамилия
|
||||
</div>
|
||||
<input type="text" class="form__input-text" placeholder="Введите фамилию">
|
||||
</label>
|
||||
<label class="form__log">
|
||||
<div class="form__field-title">
|
||||
Введите логин
|
||||
</div>
|
||||
<input type="text" class="form__input-text" placeholder="Введите login" name = "login">
|
||||
</label>
|
||||
<label class="form__log">
|
||||
<div class="form__field-title">
|
||||
Введите email
|
||||
</div>
|
||||
<input type="text" class="form__input-text" placeholder="Введите email">
|
||||
</label>
|
||||
<label class="form__log">
|
||||
<div class="form__field-title">
|
||||
Введите пароль
|
||||
</div>
|
||||
<input type="text" class="form__input-text" placeholder="Введите пароль" name = "password">
|
||||
</label>
|
||||
</div>
|
||||
<div class="form__btns">
|
||||
<div class="form__controls">
|
||||
<div class="form__controls-btns clearfix">
|
||||
<div class="form__container-left">
|
||||
<p class="form__field-title">
|
||||
Пол
|
||||
</p>
|
||||
<div class="form__controls-left">
|
||||
<label class="form__radio">
|
||||
<input type="radio" name="review" class="form__radio-elem" checked>
|
||||
<div class="form__radio-fake"></div>
|
||||
<div class="form__radio-text">Муж.</div>
|
||||
</label>
|
||||
<label class="form__radio">
|
||||
<input type="radio" name="review" class="form__radio-elem" >
|
||||
<div class="form__radio-fake"></div>
|
||||
<div class="form__radio-text ">Жен.</div>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form__controls-right">
|
||||
<button type="submit" value="Отправить" class="form__submit" >Регистрация</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<!-- заглушка -->
|
||||
<footer class="footer clearfix">
|
||||
<div class="container">
|
||||
<div class="footer-q clearfix">
|
||||
<p class="footer-full-text">Сделано с любовью и старанием на курсе ВГУ "Тестирование ПО" <br> Автор работы: <b class="footer-text_name">Трухачев Сергей</b> </p>
|
||||
</div>
|
||||
<div class="footer-q clearfix">
|
||||
<a href="/" class="logo-text">j.a.r.v.i.s</a>
|
||||
</div>
|
||||
<div class="footer-q clearfix">
|
||||
<p class="footer-messeger_text">Наши социальные сети</p>
|
||||
<ul class="footer-messeger">
|
||||
<li class="footer-messeger__item ">
|
||||
<a href="" class="footer-messeger__link">
|
||||
<img src="{{ url_for('static', filename='./img/afrodita/vk.png') }}" class="footer-messeger__icon" alt="">
|
||||
</a>
|
||||
</li>
|
||||
<li class="footer-messeger__item">
|
||||
<a href="" class="footer-messeger__link ">
|
||||
<img src="{{ url_for('static', filename='./img/afrodita/fb.png') }}" class="footer-messeger__icon" alt="">
|
||||
</a>
|
||||
</li>
|
||||
<li class="footer-messeger__item">
|
||||
<a href="" class="footer-messeger__link">
|
||||
<img src="{{ url_for('static', filename='./img/afrodita/google.png') }}" class="footer-messeger__icon" alt="">
|
||||
</a>
|
||||
</li>
|
||||
<li class="footer-messeger__item">
|
||||
<a href="" class="footer-messeger__link">
|
||||
<img src="{{ url_for('static', filename='./img/afrodita/twitter.png') }}" class="footer-messeger__icon" alt="">
|
||||
</a>
|
||||
</li>
|
||||
<li class="footer-messeger__item">
|
||||
<a href="" class="footer-messeger__link">
|
||||
<img src="{{ url_for('static', filename='./img/afrodita/mail.png') }}" class="footer-messeger__icon" alt="">
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
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