blck

ephemeral pastebin/url shortener
git clone https://git.parazyd.org/blck
Log | Files | Refs | README | LICENSE

commit 443efe3bbe1385dd0fb56efe644740f80ebe820a
parent 0005e1c0b0304bb18558dab6e96b5f43ea2059ed
Author: parazyd <parazyd@dyne.org>
Date:   Sun, 19 Mar 2017 23:56:35 +0100

don't hardcode website url

Diffstat:
Mblck.py | 16+++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/blck.py b/blck.py @@ -2,20 +2,18 @@ # copyleft (c) 2017 - parazyd # see LICENSE file for details +import flask import random import re import os import string import sys -from flask import Flask, render_template, request, redirect -app = Flask(__name__) - -appurl = "http://blck.cf" +app = flask.Flask(__name__) @app.route("/") def main(): - return render_template("index.html") + return flask.render_template("index.html") @app.route("/u/<urlshort>") @@ -28,14 +26,14 @@ def u(urlshort): except: return "could not find url\n" - if "curl" not in request.headers.get('User-Agent'): - return redirect(realurl, code=301) + if "curl" not in flask.request.headers.get('User-Agent'): + return flask.redirect(realurl, code=301) else: return realurl + '\n' @app.route("/s", methods=['POST']) def s(): - url = request.form['url'] + url = flask.request.form['url'] if not url: return "invalid data\n" @@ -63,7 +61,7 @@ def s(): except: return "could not save url\n" - return appurl + '/u/' + urlshort + '\n' + return flask.request.url_root + 'u/' + urlshort + '\n' def genid(size=4, chars=string.ascii_uppercase + string.ascii_lowercase):