Commit 4a26b469 authored by Emanuele Santoro's avatar Emanuele Santoro

Use http://musho:9000 for links

parent be84b8c9
......@@ -6,6 +6,7 @@ musho = Flask(__name__)
links = dict()
page_cache = dict()
musho_url = "http://localhost:9000"
def page(path) :
if path not in page_cache :
......@@ -13,11 +14,9 @@ def page(path) :
page_cache[path] = contents
return page_cache[path]
@musho.route("/")
def index() :
return page("templates/index.html")
#return open("views/index.html", "r").read()
@musho.route("/save", methods=['POST'])
def saveLink() :
......@@ -26,11 +25,8 @@ def saveLink() :
hash.update(url.encode('ascii','ignore'))
digest = hash.hexdigest()
short_url = digest[0:8]
links[short_url] = url
full_url = "http://localhost:9000/l/" + short_url
full_url = musho_url +"/l/" + short_url
return render_template('shortened_link.html', url=full_url)
......@@ -41,8 +37,6 @@ def resolveLink(link_id):
return redirect(url)
else :
return redirect("/")
if __name__ == "__main__" :
debug = os.getenv("DEBUG", None)
......@@ -53,5 +47,8 @@ if __name__ == "__main__" :
port = int(os.getenv("PORT", "9000"))
except :
pass
musho_url = os.getenv("MUSHO_URL", "http://localhost:%d" % port)
print("MUSHO_URL:\t\t%s" % musho_url)
print("PORT:\t\t\t%d" % port)
print("DEBUG:\t\t\t%s" % debug)
musho.run(port=port)
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