Esempio n. 1
0
 def get(self, short_id):
     """Renders a template with a form for submitting a link
     """
     short_info = load_shortlink(self.db_conn, short_id)
     if short_info:
         return self.redirect(short_info['link'])
     else:
         return self.render_template('errors.html', **{'error_code': 500})
Esempio n. 2
0
 def get(self, short_id):
     """Renders a template with a form for submitting a link
     """
     short_info = load_shortlink(self.db_conn, short_id)
     if short_info:
         return self.redirect(short_info["link"])
     else:
         return self.render_template("errors.html", **{"error_code": 500})
Esempio n. 3
0
    def get(self):
        short_id = self.get_argument("short_id", None)
        status_code = 404  # default to not found

        short_info = load_shortlink(self.db_conn, short_id)

        if short_info:
            status_code = 200
            url = short_info["link"]
        else:
            url = "Pssshh... NADA!"

        data = {"url": url, "status_code": status_code}

        self.set_body(json.dumps(data))
        return self.render(status_code=200)
Esempio n. 4
0
    def get(self):
        short_id = self.get_argument('short_id', None)
        status_code = 404 # default to not found
        
        short_info = load_shortlink(self.db_conn, short_id)

        if short_info:
            status_code = 200
            url = short_info['link']
        else:
            url = 'Pssshh... NADA!'
        
        data = {
            'url': url,
            'status_code': status_code
        }

        self.set_body(json.dumps(data))
        return self.render(status_code=200)