diff --git a/urlshort.py b/urlshort.py index bf87ca3..6bf02b1 100644 --- a/urlshort.py +++ b/urlshort.py @@ -1,5 +1,6 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- +#vim: set tabstop=2 from flask import Flask, g, request, render_template, redirect import sqlite3 import random @@ -27,6 +28,7 @@ def teardown_request(exception): @app.route("/") @limiter.exempt def root(): + return "Welcome to root!" @app.route("/") @@ -34,7 +36,7 @@ def root(): def paste(pasteID): target = query_db("SELECT target FROM pastes WHERE paste_url = ?", [pasteID], one=True) if target is None: - return "Shorturl not found!" + return redirect("/", 301) else: url = urlparse(target["target"]) if url.scheme is "": @@ -45,7 +47,7 @@ def paste(pasteID): @app.route("/new") @limiter.exempt -def new_paste(): +def new_short(): target_url = request.args.get("target", "") paste_id = add_redirect(target_url, 1) return render_template("new_paste.html", paste_id=paste_id)