CatOrNot/app/routes.py

19 lines
526 B
Python
Raw Normal View History

2018-12-11 00:32:28 +01:00
from flask import Flask
from flask import render_template
from app.forms import UploadForm
from app import app
from app import cat_recognition as cat
from app import picture_downloader as downloader
@app.route('/', methods=['GET', 'POST'])
def index():
form = UploadForm()
if form.validate_on_submit():
content = downloader.get_image_from_url(form.url.data)
if cat.is_cat(content):
return "Cat!"
else:
return "Not!"
return render_template('index.html', form=form)