From fa0a6461d49653583e3dd9a2a28d28d5a7096c0b Mon Sep 17 00:00:00 2001 From: lza_menace Date: Wed, 23 Sep 2020 22:13:28 -0700 Subject: [PATCH] nicer 404 and missing page redirects --- suchwow/app.py | 7 ++++--- suchwow/routes/post.py | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/suchwow/app.py b/suchwow/app.py index 430dc0c..d988bbc 100644 --- a/suchwow/app.py +++ b/suchwow/app.py @@ -1,7 +1,7 @@ import json from os import makedirs -from flask import Flask, request, session -from flask import render_template, flash +from flask import Flask, request, session, redirect +from flask import render_template, flash, url_for from flask_session import Session from suchwow import config from suchwow.models import Post, Profile, Comment, Notification, db @@ -41,7 +41,8 @@ def about(): @app.errorhandler(404) def not_found(error): - return "nothin there, brah" + flash("nothing there, brah") + return redirect(url_for("index")) @app.cli.command("init") def init(): diff --git a/suchwow/routes/post.py b/suchwow/routes/post.py index 4c764e3..787496d 100644 --- a/suchwow/routes/post.py +++ b/suchwow/routes/post.py @@ -46,7 +46,8 @@ def read(id): transfers=transfers ) else: - return "no meme there brah" + flash("No meme there, brah") + return redirect(url_for("index")) @bp.route("/post/create", methods=["GET", "POST"]) @login_required