2020-07-19 20:01:03 +00:00
|
|
|
from flask import render_template, redirect, request, url_for
|
2020-07-20 14:55:19 +00:00
|
|
|
from tiny0 import app, db
|
2020-07-18 16:40:51 +00:00
|
|
|
from tiny0.forms import URLForm
|
2020-07-20 14:55:19 +00:00
|
|
|
from tiny0.models import URL
|
2020-07-18 13:10:03 +00:00
|
|
|
#from token import gen_valid_token
|
|
|
|
|
|
2020-07-18 16:40:51 +00:00
|
|
|
# Index Page
|
|
|
|
|
@app.route("/", methods=['GET', 'POST'])
|
2020-07-18 13:10:03 +00:00
|
|
|
def index():
|
2020-07-19 20:01:03 +00:00
|
|
|
# Create a instance of the form
|
|
|
|
|
form = URLForm()
|
2020-07-18 16:40:51 +00:00
|
|
|
|
2020-07-19 20:01:03 +00:00
|
|
|
# If the form was valid
|
|
|
|
|
if form.validate_on_submit():
|
2020-07-20 14:09:03 +00:00
|
|
|
return render_template("url.html", url=form.url.data)
|
2020-07-18 16:40:51 +00:00
|
|
|
|
2020-07-19 20:01:03 +00:00
|
|
|
# If the form was invalid or not submitted
|
2020-07-18 16:40:51 +00:00
|
|
|
else:
|
2020-07-19 20:01:03 +00:00
|
|
|
# Return the index page with the form
|
2020-07-18 16:40:51 +00:00
|
|
|
return render_template("index.html", form=form)
|