Compare commits

..

No commits in common. '4e9590e0773502724d8f227d5d1d96be29b1f6ca' and 'bf105f704888f0140371aed652ffeac6eabef71f' have entirely different histories.

  1. 5
      app/forms.py
  2. 21
      app/routes.py
  3. 14
      app/templates/admin.html
  4. 9
      app/templates/base.html
  5. 15
      app/templates/index.html
  6. 9
      app/templates/login.html
  7. 5
      app/templates/result.html

@ -4,11 +4,6 @@ from wtforms.validators import ValidationError, DataRequired, Email, EqualTo
from app.models import User from app.models import User
class CheckForm(FlaskForm):
text = StringField('Text to be checked', validators=[DataRequired()])
submit = SubmitField('Check')
class LoginForm(FlaskForm): class LoginForm(FlaskForm):
username = StringField('Username', validators=[DataRequired()]) username = StringField('Username', validators=[DataRequired()])
password = PasswordField('Password', validators=[DataRequired()]) password = PasswordField('Password', validators=[DataRequired()])

@ -1,25 +1,16 @@
from app import app from app import app
from app import db from app import db
from app.forms import LoginForm, RegistrationForm, CheckForm from app.forms import LoginForm, RegistrationForm
from app.models import User from app.models import User
from flask import render_template, flash, redirect, url_for, request from flask import render_template, flash, redirect, url_for
from flask_login import current_user, login_user, logout_user from flask_login import current_user, login_user, logout_user
from flask_login import login_required from flask_login import login_required
@app.route('/') @app.route('/')
@app.route('/index', methods=['GET', 'POST']) @app.route('/index')
def index(): def index():
form = CheckForm() return "Hello, World!"
if request.method == 'POST':
text = request.form['text']
return render_template('result.html', title='Result', text=text)
else:
if form.validate_on_submit():
flash('Check requested for text {}'.format(
form.text.data))
return redirect(url_for('index'))
return render_template('index.html', title='Check', form=form)
@app.route('/register', methods=['GET', 'POST']) @app.route('/register', methods=['GET', 'POST'])
@ -40,7 +31,7 @@ def register():
@app.route('/login', methods=['GET', 'POST']) @app.route('/login', methods=['GET', 'POST'])
def login(): def login():
if current_user.is_authenticated: if current_user.is_authenticated:
return redirect(url_for('admin')) return redirect(url_for('index'))
form = LoginForm() form = LoginForm()
if form.validate_on_submit(): if form.validate_on_submit():
user = User.query.filter_by(username=form.username.data).first() user = User.query.filter_by(username=form.username.data).first()
@ -55,7 +46,7 @@ def login():
@app.route('/admin') @app.route('/admin')
@login_required @login_required
def admin(): def admin():
return render_template('admin.html') return "Hello, World!"
@app.route('/logout') @app.route('/logout')

@ -1,14 +0,0 @@
{% extends "base.html" %}
{% block content %}
<div>
Dildebaslar:
<a href="{{ url_for('index') }}">Home</a>
{% if current_user.is_anonymous %}
<a href="{{ url_for('login') }}">Login</a>
{% else %}
<a href="{{ url_for('logout') }}">Logout</a>
{% endif %}
</div>
<h1>Hi, {{ current_user.username }}!</h1>
{% endblock %}

@ -32,6 +32,15 @@
{% endif %} {% endif %}
{% endwith %} {% endwith %}
{% block body %}{% endblock %} {% block body %}{% endblock %}
<div>
Microblog:
<a href="{{ url_for('index') }}">Home</a>
{% if current_user.is_anonymous %}
<a href="{{ url_for('login') }}">Login</a>
{% else %}
<a href="{{ url_for('logout') }}">Logout</a>
{% endif %}
</div>
<div class="container" align="center"> <div class="container" align="center">
<div class="jumbotron text-center" style="width: 50% ;"> <div class="jumbotron text-center" style="width: 50% ;">

@ -1,15 +0,0 @@
{% extends "base.html" %}
{% block content %}
<div class="container" align="center">
<div class="row">
<div class="col-md-6 mx-md-auto">
<form action="" method="post" novalidate >
<textarea class="form-control" rows="12" name="text" style="width: 100% ; height: 100%" ></textarea>
<input type="submit" value="Metni incele" class="btn btn-primary btn-block">
</form>
</div>
</div>
</div>
{% endblock %}

@ -1,15 +1,6 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block content %} {% block content %}
<div>
Dildebaslar:
<a href="{{ url_for('index') }}">Home</a>
{% if current_user.is_anonymous %}
<a href="{{ url_for('login') }}">Login</a>
{% else %}
<a href="{{ url_for('logout') }}">Logout</a>
{% endif %}
</div>
<h1>Hi, {{ current_user.username }}!</h1> <h1>Hi, {{ current_user.username }}!</h1>
<h1>Sign In</h1> <h1>Sign In</h1>
<form action="" method="post" novalidate> <form action="" method="post" novalidate>

@ -1,5 +0,0 @@
{% extends "base.html" %}
{% block content %}
{{ text }}
{% endblock %}
Loading…
Cancel
Save