def route_micro(micro):
'''
Micro to real URL redirection handler.
'''
try:
temp = lookup_micro(micro)
if urlcheck(temp):
return redirect(temp)
elif domaincheck(temp):
return redirect("http://" + temp)
elif ipcheck(temp.split(':')[0]) and urlcheck('http://' + temp):
# checks for plain ip or an ip with something after it
return redirect("http://" + temp)
else:
abort(404)
except Exception as e:
# If micro is not registered, handle the exception from trying to look
# it up and raise a 404 HTTP error.
sys.stderr.write(str(e))
abort(404)
评论列表
文章目录