Commit 9aeb1078 authored by Emanuele Santoro's avatar Emanuele Santoro

Better logging

parent 287edd1b
......@@ -61,14 +61,18 @@ def saveLink() :
db.session.add(new_link)
db.session.commit()
full_url = musho_url +"/l/" + short_url
print("Sortened %s -- %s -- %s " % (short_url, remote_ip, now) )
print("[save-url] url: %s -- client: %s -- now: %s " % (short_url, remote_ip, now) )
return render_template('shortened_link.html', url=full_url)
@musho.route("/l/<string:short_url>")
def resolveLink(short_url):
if debug:
print("Risolvo il link '%s'" % short_url)
now = time.strftime("%d-%b-%Y %H:%m")
remote_ip = request.remote_addr
if request.headers.getlist("X-Forwarded-For"):
remote_ip = request.headers.getlist("X-Forwarded-For")[0]
print("[resolve-url] url: '%s' -- client: '%s' -- now: '%s'" % (short_url, remote_ip, now))
target = Link.query.filter_by(short_url=short_url).first()
if target is not None :
return redirect(target.full_url)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment