Add template for check text and result

master
Neslihan 4 years ago
parent 9de55402f9
commit 5f5ca9fda3
  1. 5
      app/forms.py
  2. 17
      app/routes.py
  3. 15
      app/templates/index.html
  4. 5
      app/templates/result.html

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

@ -1,16 +1,25 @@
from app import app
from app import db
from app.forms import LoginForm, RegistrationForm
from app.forms import LoginForm, RegistrationForm, CheckForm
from app.models import User
from flask import render_template, flash, redirect, url_for
from flask import render_template, flash, redirect, url_for, request
from flask_login import current_user, login_user, logout_user
from flask_login import login_required
@app.route('/')
@app.route('/index')
@app.route('/index', methods=['GET', 'POST'])
def index():
return "Hello, World!"
form = CheckForm()
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'])

@ -0,0 +1,15 @@
{% 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 %}

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