commit to push to gitlab

This commit is contained in:
Andrew Davidson 2014-12-11 21:56:10 -05:00
parent 22efbe5929
commit 9017cddbce

View file

@ -4,7 +4,9 @@ import bottle
from bottle import default_app, get, post, route, run, request, template, static_file, redirect
from os.path import isdir
from string import lower, split
from urllib import unquote
import string
from urllib import unquote, urlopen
from urlparse import urlparse
import shutil
from datetime import datetime
import re
@ -12,10 +14,6 @@ import Image
from markdown2 import markdown
import MySQLdb
from contextlib import closing
from urllib import urlopen
from urlparse import urlparse
from contextlib import closing
import string
import random
@ -84,6 +82,13 @@ def mkpass(size=10):
return string.join([random.choice(validChars) for x in range(size)],"")
def mkshort(size=4):
validChars = string.ascii_letters + string.digits
validChars = validChars.strip("oO01l")
return string.join([random.choice(validChars) for x in range(size)],"")
def get_generated(domain):
get = 'SELECT password FROM secrets_gen WHERE base_url LIKE "%'+get_domain(domain)+'%" LIMIT 1'
create = 'INSERT INTO secrets_gen (base_url, password) VALUES ("'+get_domain(domain)+'","'+mkpass()+'")'
@ -717,10 +722,9 @@ def mkdir():
# Let's build in the url shortening functionality.
@route('/short/<short>')
@route('/short/')
@route('/short')
@get('/short/<short>')
def short(short = ''):
body = []
if short:
query = 'SELECT url,public FROM short WHERE `key` = "'+short+'" LIMIT 1;'
@ -729,17 +733,20 @@ def short(short = ''):
if url:
redirect(url[0])
else:
body = ['Short url "'+short+'" does not exist.']
return template('templates/public', content='\n'.join(body),\
title='Error')
else:
body = ['You must provide a short url.']
return template('templates/public', content='\n'.join(body),\
title='Error')
@get('/short/')
@get('/short')
def mkshort(short = ''):
body = []
body.append("<h3>Create Shortened URL.</h3>")
body.append('<form method="POST" action="/short">')
body.append('<input type="submit">')
body.append('</form>')
return template('templates/public', content='\n'.join(body),\
title='Create Shortened URL' + short)
# Let's make a place to store my secrets