diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..593bd5f --- /dev/null +++ b/.gitignore @@ -0,0 +1,162 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +.idea/ +db/ +*.db \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 26d3352..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2d..0000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 264d191..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index e4508d0..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/project_LP.iml b/.idea/project_LP.iml deleted file mode 100644 index d0876a7..0000000 --- a/.idea/project_LP.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..69d70f8 --- /dev/null +++ b/app.py @@ -0,0 +1,171 @@ +from datetime import datetime + +from flask import Flask, render_template, url_for, redirect, request, flash +from flask_login import LoginManager, login_user, logout_user, current_user,login_required +from flask_login import UserMixin +from flask_sqlalchemy import SQLAlchemy +from werkzeug.security import generate_password_hash, check_password_hash +from flask_migrate import Migrate +from forms import LoginForm, RegistrationForm +import shortener +from sqlalchemy import MetaData + +app = Flask(__name__) +app.config.from_object('config') +app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///list.db' +app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False +convention = { + "ix": 'ix_%(column_0_label)s', + "uq": "uq_%(table_name)s_%(column_0_name)s", + "ck": "ck_%(table_name)s_%(constraint_name)s", + "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s", + "pk": "pk_%(table_name)s" +} + +metadata = MetaData(naming_convention=convention) +db = SQLAlchemy(app,metadata=metadata) +login_manager = LoginManager() +login_manager.init_app(app) +login_manager.login_view = 'login' +migrate = Migrate(app, db) + + + +@login_manager.user_loader +def load_user(user_id): + return User.query.get(user_id) + + +shortened_urls = {} + + +class Article(db.Model): + id = db.Column(db.Integer, primary_key=True) + full_url = db.Column(db.String, nullable=False) + short_url = db.Column(db.String, nullable=False) + date = db.Column(db.DateTime, default=datetime.utcnow) + user_id = db.Column(db.Integer, db.ForeignKey('user.id')) + + def __repr__(self): + return '
' % self.id + + +class User(db.Model, UserMixin): + id = db.Column(db.Integer, primary_key=True) + username = db.Column(db.String(64), index=True, unique=True) + password = db.Column(db.String(128)) + role = db.Column(db.String(10), index=True) + + + + def set_password(self, password): + self.password = generate_password_hash(password) + + def check_password(self, password): + return check_password_hash(self.password, password) + + def __repr__(self): + return ''.format(self.username) + + +@app.route("/", methods=['GET', 'POST']) +def index(): + if request.method == 'POST': + full_url = request.form['full_url'] + short_url = shortener.generate_short_url() + while short_url in shortened_urls: + short_url = shortener.generate_short_url() + shortened_urls[short_url] = full_url + if current_user.is_authenticated: + article = Article(full_url=full_url, short_url=short_url,user_id=current_user.id) + try: + db.session.add(article) + db.session.commit() + return redirect('short_url') + except: + return 'При преобразовании возникла проблема' + flash('Для просмотра истории создания ваших ссылок необходимо войти или зарегистрироваться') + return render_template('nonreg.html',full_url=full_url,short_url=short_url) + return render_template('index.html') + + +@app.route('/short_url') +@login_required +def short_url(): + #article = Article.query.order_by(Article.date).all() + res = db.session.query(Article,User).join(Article, User.id == Article.user_id).all() + return render_template('short_url.html', res=res) + + +@app.route('/login') +def login(): + if current_user.is_authenticated: + return redirect(url_for('index')) + title = "Авторизация" + login_form = LoginForm() + return render_template('login.html', page_title=title, form=login_form) + + +@app.route('/process-login', methods=['POST']) +def process_login(): + form = LoginForm() + if form.validate_on_submit(): + user = User.query.filter_by(username=form.username.data).first() + if user and user.check_password(form.password.data): + login_user(user) + flash('Вы вошли на сайт') + return redirect(url_for('index')) + flash('Неправильное имя пользователя или пароль') + return redirect(url_for('login')) + + +@app.route('/logout') +@login_required +def logout(): + logout_user() + flash('Вы успешно вышли') + return redirect(url_for('index')) + +@app.route('/register') +def register(): + if current_user.is_authenticated: + return redirect(url_for('index')) + form = RegistrationForm() + title = "Регистрация" + return render_template('registration.html',page_title=title, form=form) + + +@app.route('/process-reg', methods=['POST']) +def process_reg(): + form = RegistrationForm() + if form.validate_on_submit(): + new_user = User(username=form.username.data,role='user') + new_user.set_password(form.password.data) + db.session.add(new_user) + db.session.commit() + flash('Вы успешно зарегистрировались!') + return redirect(url_for('login')) + else: + for field, errors in form.errors.items(): + for error in errors: + flash('Ошибка в поле "{}": - {}'.format( + getattr(form, field).label.text, + error + )) + return redirect(url_for('user.register')) + + +@app.route('/') +def redirect_url(short_url): + try: + f = Article.query.filter_by(short_url=short_url).one() + if f.full_url: + return redirect(f.full_url) + except: + return 'Url not found' + + +if __name__ == '__main__': + with app.app_context(): # <--- without these two lines, + db.create_all() # <--- we get the OperationalError in the title + app.run(debug=True) diff --git a/config.py b/config.py new file mode 100644 index 0000000..f553e91 --- /dev/null +++ b/config.py @@ -0,0 +1,2 @@ +CSRF_ENABLED = True +SECRET_KEY = 'you-will-never-guess' \ No newline at end of file diff --git a/create_admin.py b/create_admin.py new file mode 100644 index 0000000..1162274 --- /dev/null +++ b/create_admin.py @@ -0,0 +1,25 @@ +from getpass import getpass +import sys + +from app import app +from app import User,db + + +with app.app_context(): + username = input('Введите имя пользователя: ') + + if User.query.filter(User.username == username).count(): + print('Такой пользователь уже есть') + sys.exit(0) + + password = getpass('Введите пароль: ') + password2 = getpass('Повторите пароль: ') + if not password == password2: + sys.exit(0) + + new_user = User(username=username, role='admin') + new_user.set_password(password) + + db.session.add(new_user) + db.session.commit() + print('User with id {} added'.format(new_user.id)) \ No newline at end of file diff --git a/forms.py b/forms.py new file mode 100644 index 0000000..22f1467 --- /dev/null +++ b/forms.py @@ -0,0 +1,27 @@ +from flask_wtf import FlaskForm +from wtforms import StringField, PasswordField, SubmitField +from wtforms.validators import DataRequired, EqualTo, ValidationError + + + + +class LoginForm(FlaskForm): + username = StringField('Имя пользователя', validators=[DataRequired()], + render_kw={"class": "form-control"}) + password = PasswordField('Пароль', validators=[DataRequired()], + render_kw={"class": "form-control"}) + submit = SubmitField('Отправить', render_kw={"class": "btn btn-primary"}) + +class RegistrationForm(FlaskForm): + username = StringField('Имя пользователя', validators=[DataRequired()], + render_kw={"class": "form-control"}) + password = PasswordField('Пароль', validators=[DataRequired()], + render_kw={"class": "form-control"}) + password2 = PasswordField('Повторите пароль',validators=[DataRequired(),EqualTo('password')], + render_kw={"class": "form-control"}) + submit = SubmitField('Отправить!',render_kw={"class": "btn btn-primary"}) + + # def validate_username(self, username): + # users_count = User.query.filter_by(username=username.data).count() + # if users_count > 0: + # raise ValidationError('Пользователь с таким именем уже зарегистрирован') \ No newline at end of file diff --git a/migrations/README b/migrations/README new file mode 100644 index 0000000..0e04844 --- /dev/null +++ b/migrations/README @@ -0,0 +1 @@ +Single-database configuration for Flask. diff --git a/migrations/alembic.ini b/migrations/alembic.ini new file mode 100644 index 0000000..ec9d45c --- /dev/null +++ b/migrations/alembic.ini @@ -0,0 +1,50 @@ +# A generic, single database configuration. + +[alembic] +# template used to generate migration files +# file_template = %%(rev)s_%%(slug)s + +# set to 'true' to run the environment during +# the 'revision' command, regardless of autogenerate +# revision_environment = false + + +# Logging configuration +[loggers] +keys = root,sqlalchemy,alembic,flask_migrate + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = WARN +handlers = console +qualname = + +[logger_sqlalchemy] +level = WARN +handlers = +qualname = sqlalchemy.engine + +[logger_alembic] +level = INFO +handlers = +qualname = alembic + +[logger_flask_migrate] +level = INFO +handlers = +qualname = flask_migrate + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(levelname)-5.5s [%(name)s] %(message)s +datefmt = %H:%M:%S diff --git a/migrations/env.py b/migrations/env.py new file mode 100644 index 0000000..4c97092 --- /dev/null +++ b/migrations/env.py @@ -0,0 +1,113 @@ +import logging +from logging.config import fileConfig + +from flask import current_app + +from alembic import context + +# this is the Alembic Config object, which provides +# access to the values within the .ini file in use. +config = context.config + +# Interpret the config file for Python logging. +# This line sets up loggers basically. +fileConfig(config.config_file_name) +logger = logging.getLogger('alembic.env') + + +def get_engine(): + try: + # this works with Flask-SQLAlchemy<3 and Alchemical + return current_app.extensions['migrate'].db.get_engine() + except (TypeError, AttributeError): + # this works with Flask-SQLAlchemy>=3 + return current_app.extensions['migrate'].db.engine + + +def get_engine_url(): + try: + return get_engine().url.render_as_string(hide_password=False).replace( + '%', '%%') + except AttributeError: + return str(get_engine().url).replace('%', '%%') + + +# add your model's MetaData object here +# for 'autogenerate' support +# from myapp import mymodel +# target_metadata = mymodel.Base.metadata +config.set_main_option('sqlalchemy.url', get_engine_url()) +target_db = current_app.extensions['migrate'].db + +# other values from the config, defined by the needs of env.py, +# can be acquired: +# my_important_option = config.get_main_option("my_important_option") +# ... etc. + + +def get_metadata(): + if hasattr(target_db, 'metadatas'): + return target_db.metadatas[None] + return target_db.metadata + + +def run_migrations_offline(): + """Run migrations in 'offline' mode. + + This configures the context with just a URL + and not an Engine, though an Engine is acceptable + here as well. By skipping the Engine creation + we don't even need a DBAPI to be available. + + Calls to context.execute() here emit the given string to the + script output. + + """ + url = config.get_main_option("sqlalchemy.url") + context.configure( + url=url, target_metadata=get_metadata(), literal_binds=True + ) + + with context.begin_transaction(): + context.run_migrations() + + +def run_migrations_online(): + """Run migrations in 'online' mode. + + In this scenario we need to create an Engine + and associate a connection with the context. + + """ + + # this callback is used to prevent an auto-migration from being generated + # when there are no changes to the schema + # reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html + def process_revision_directives(context, revision, directives): + if getattr(config.cmd_opts, 'autogenerate', False): + script = directives[0] + if script.upgrade_ops.is_empty(): + directives[:] = [] + logger.info('No changes in schema detected.') + + conf_args = current_app.extensions['migrate'].configure_args + if conf_args.get("process_revision_directives") is None: + conf_args["process_revision_directives"] = process_revision_directives + + connectable = get_engine() + + with connectable.connect() as connection: + context.configure( + connection=connection, + target_metadata=get_metadata(), + **conf_args + ) + + with context.begin_transaction(): + context.run_migrations() + + +if context.is_offline_mode(): + run_migrations_offline() +else: + run_migrations_online() diff --git a/migrations/script.py.mako b/migrations/script.py.mako new file mode 100644 index 0000000..2c01563 --- /dev/null +++ b/migrations/script.py.mako @@ -0,0 +1,24 @@ +"""${message} + +Revision ID: ${up_revision} +Revises: ${down_revision | comma,n} +Create Date: ${create_date} + +""" +from alembic import op +import sqlalchemy as sa +${imports if imports else ""} + +# revision identifiers, used by Alembic. +revision = ${repr(up_revision)} +down_revision = ${repr(down_revision)} +branch_labels = ${repr(branch_labels)} +depends_on = ${repr(depends_on)} + + +def upgrade(): + ${upgrades if upgrades else "pass"} + + +def downgrade(): + ${downgrades if downgrades else "pass"} diff --git a/migrations/versions/31ee6a74b04d_added_foreingkey_user_id.py b/migrations/versions/31ee6a74b04d_added_foreingkey_user_id.py new file mode 100644 index 0000000..fea8224 --- /dev/null +++ b/migrations/versions/31ee6a74b04d_added_foreingkey_user_id.py @@ -0,0 +1,34 @@ +"""added foreingkey user_id + +Revision ID: 31ee6a74b04d +Revises: 649762b05dd7 +Create Date: 2024-01-29 20:05:57.928626 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '31ee6a74b04d' +down_revision = '649762b05dd7' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('article', schema=None) as batch_op: + batch_op.drop_constraint('fk_article_user_id_user', type_='foreignkey') + batch_op.create_foreign_key(batch_op.f('fk_article_user_id_user'), 'user', ['user_id'], ['id']) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('article', schema=None) as batch_op: + batch_op.drop_constraint(batch_op.f('fk_article_user_id_user'), type_='foreignkey') + batch_op.create_foreign_key('fk_article_user_id_user', 'user', ['user_id'], ['username']) + + # ### end Alembic commands ### diff --git a/migrations/versions/649762b05dd7_added_foreingkey_user_name.py b/migrations/versions/649762b05dd7_added_foreingkey_user_name.py new file mode 100644 index 0000000..f453a0f --- /dev/null +++ b/migrations/versions/649762b05dd7_added_foreingkey_user_name.py @@ -0,0 +1,34 @@ +"""added foreingkey user_name + +Revision ID: 649762b05dd7 +Revises: ca9a586bad41 +Create Date: 2024-01-29 20:03:58.860250 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '649762b05dd7' +down_revision = 'ca9a586bad41' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('article', schema=None) as batch_op: + batch_op.drop_constraint('fk_article_user_id_user', type_='foreignkey') + batch_op.create_foreign_key(batch_op.f('fk_article_user_id_user'), 'user', ['user_id'], ['username']) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('article', schema=None) as batch_op: + batch_op.drop_constraint(batch_op.f('fk_article_user_id_user'), type_='foreignkey') + batch_op.create_foreign_key('fk_article_user_id_user', 'user', ['user_id'], ['id']) + + # ### end Alembic commands ### diff --git a/migrations/versions/ca9a586bad41_added_foreingkey_user_id.py b/migrations/versions/ca9a586bad41_added_foreingkey_user_id.py new file mode 100644 index 0000000..0263c89 --- /dev/null +++ b/migrations/versions/ca9a586bad41_added_foreingkey_user_id.py @@ -0,0 +1,34 @@ +"""added foreingkey user_id + +Revision ID: ca9a586bad41 +Revises: +Create Date: 2024-01-29 19:29:25.698347 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'ca9a586bad41' +down_revision = None +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('article', schema=None) as batch_op: + batch_op.add_column(sa.Column('user_id', sa.Integer(), nullable=True)) + batch_op.create_foreign_key(None, 'user', ['user_id'], ['id']) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('article', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_column('user_id') + + # ### end Alembic commands ### diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..92b85a2 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,16 @@ +blinker==1.7.0 +click==8.1.7 +Flask==2.1.3 +Flask-Login==0.6.3 +Flask-SQLAlchemy==2.5.1 +Flask-WTF==1.2.1 +Flask-Migrate==2.3.1 +greenlet==3.0.3 +itsdangerous==2.1.2 +Jinja2==3.1.2 +MarkupSafe==2.1.3 +SQLAlchemy==1.4.49 +typing_extensions==4.9.0 +Werkzeug==2.2.2 +wtf==0.1 +WTForms==3.1.2 diff --git a/shortener.py b/shortener.py new file mode 100644 index 0000000..5ce6c92 --- /dev/null +++ b/shortener.py @@ -0,0 +1,7 @@ +import random +LENGHT = 6 +CHARACTERS = 'ABCDEFGHJKLMNOPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz234567890' # алфавит для генерации короткой ссылки + +def generate_short_url(): + short_url = ''.join(random.choices(CHARACTERS, k=LENGHT)) + return short_url \ No newline at end of file diff --git a/main.py b/static/css/main.css similarity index 100% rename from main.py rename to static/css/main.css diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..c2270c8 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,33 @@ + + + + + + + + + {% block title %}{% endblock %} + + + + {% block body %}{% endblock %} +
+
+ +

© 2024 by Shirokov Nikolay

+
+
+ + + \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..e1220cc --- /dev/null +++ b/templates/index.html @@ -0,0 +1,34 @@ +{% extends 'base.html' %} + +{% block title %} +Короче +{% endblock %} + + +{% block body %} +{% with messages = get_flashed_messages() %} + {% if messages %} + + {% endif %} +{% endwith %} +
+
+

Короче URL

+
+

Сервис для быстрого преобразования длинной URL ссылки в более короткую

+
+
+ +
+ +
+
+
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/templates/login.html b/templates/login.html new file mode 100644 index 0000000..cc98062 --- /dev/null +++ b/templates/login.html @@ -0,0 +1,37 @@ +{% extends 'base.html' %} + +{% block title %} +{% endblock %} + +{% block body %} +{% with messages = get_flashed_messages() %} + {% if messages %} + + {% endif %} +{% endwith %} +
+ +
+
+
+

{{ page_title }}

+
+ {{ form.hidden_tag() }} +
+ {{ form.username.label }}
+ {{ form.username() }} +
+
+ {{ form.password.label }}
+ {{ form.password() }}
+
+ {{ form.submit }} +
+
+
+
+{% endblock %} diff --git a/templates/nonreg.html b/templates/nonreg.html new file mode 100644 index 0000000..eb43fb4 --- /dev/null +++ b/templates/nonreg.html @@ -0,0 +1,33 @@ +{% extends 'base.html' %} + +{% block title %} +Ваш Url +{% endblock %} + +{% block body %} +{% with messages = get_flashed_messages() %} + {% if messages %} + + {% endif %} +{% endwith %} +
+ + + + + + + + + + +
full Urlshort Url
{{ full_url }}{{ short_url }}
+
+ +{% endblock %} + + diff --git a/templates/registration.html b/templates/registration.html new file mode 100644 index 0000000..7e2fada --- /dev/null +++ b/templates/registration.html @@ -0,0 +1,43 @@ +{% extends 'base.html' %} + +{% block title %} +{% endblock %} + + + +{% block body %} +{% with messages = get_flashed_messages() %} + {% if messages %} + + {% endif %} +{% endwith %} +
+ +
+
+
+

{{ page_title }}

+
+ {{ form.hidden_tag() }} +
+ {{ form.username.label }}
+ {{ form.username() }} +
+
+ {{ form.password.label }}
+ {{ form.password() }}
+
+
+ {{ form.password2.label }}
+ {{ form.password2() }}
+
+ {{ form.submit }} +
+
+
+
+{% endblock %} diff --git a/templates/short_url.html b/templates/short_url.html new file mode 100644 index 0000000..5fb4069 --- /dev/null +++ b/templates/short_url.html @@ -0,0 +1,29 @@ +{% extends 'base.html' %} + +{% block title %} +Ваш Url +{% endblock %} + + +{% block body %} +
+ + + + + + + {% for el in res %} + + + + + + {% endfor %} + +
full Urlshort Urldate
{{ el.Article.full_url }}{{ el.Article.short_url }}{{ el.Article.date }}
+
+ +{% endblock %} + +