diff options
author | B. Stack <bgstack15@gmail.com> | 2022-02-13 19:19:03 -0500 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2022-02-13 19:19:03 -0500 |
commit | 2e5ef31e697fbd01f7438c389edb40aac60839fc (patch) | |
tree | 5e6d478a5b4de6200fe201114a8593307852a4a8 /pastebin.py | |
parent | add admin page, delete function, and APPNAME var (diff) | |
download | stackbin-2e5ef31e697fbd01f7438c389edb40aac60839fc.tar.gz stackbin-2e5ef31e697fbd01f7438c389edb40aac60839fc.tar.bz2 stackbin-2e5ef31e697fbd01f7438c389edb40aac60839fc.zip |
add redirects after delete, and simplify css calls
Diffstat (limited to 'pastebin.py')
-rw-r--r-- | pastebin.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/pastebin.py b/pastebin.py index 4c529f9..3851d01 100644 --- a/pastebin.py +++ b/pastebin.py @@ -48,6 +48,13 @@ def url_for_other_page(page): app.jinja_env.globals['url_for_other_page'] = url_for_other_page app.jinja_env.globals['appname'] = app.config['APPNAME'] +def refresh_string(delay,url): + """ + Returns a string for html content for redirecting the user back after the + requested delay, to the requested url. + """ + return f'<meta http-equiv="Refresh" content="{delay}; url={url}">' + @app.before_request def check_user_status(): g.user = None @@ -148,9 +155,10 @@ def delete_paste(paste_id): try: Paste.query.filter(Paste.id == paste.id).delete() db.session.commit() - return "OK",200 # WORKHERE: make this and the 500 redirect to admin/ + message = refresh_string(1, url_for("admin")) + "OK" + return message,200 except: - return "failure to delete object.",500 + return f"failure to delete object. Select <a href='{url_for('admin')}'>here</a> to return to the admin panel.",500 def get_all_pastes(): """ |