diff --git a/export.py b/export.py index 70d36a590f98c4ed0d6850dc6d5c929f282beea1..06bd49e1be04cf07a36de600c8a3e8b155ab8a8c 100644 --- a/export.py +++ b/export.py @@ -21,4 +21,4 @@ conn = sqlite3.connect('db/urls.db') cursor = conn.cursor() res = cursor.execute('SELECT LONG_URL, SHORT_URL FROM WEB_URL WHERE 1') #read all data from database for entries in res.fetchall(): - print(str(entries[1]).replace('"', "") + ";" + str(entries[0]).replace('"', "")) #format the data and print it to console. \ No newline at end of file + print(str(entries[1]).replace('"', "") + ";" + str(entries[0]).replace('"', "")) #format the data and print it to console. \ No newline at end of file diff --git a/import.py b/import.py index ecb6d7865345fb1e7df83322fea3d26338b5dde0..5f937af46dede37af2f5f9f6900f8e3f12cd1a82 100644 --- a/import.py +++ b/import.py @@ -37,6 +37,6 @@ with sqlite3.connect('db/urls.db') as conn: LONG_URL = lines.split(";")[1].replace("\n", "").replace("\r","") #Split the CSV at the ";" then use the seccond one and replace all linebreaks res = cursor.execute( #Insert the data in the SQL table 'INSERT INTO WEB_URL (LONG_URL, SHORT_URL) VALUES (?, ?)', - [LONG_URL, SHORT_URL] + [LONG_URL, SHORT_URL.lower()] ) counter = counter + 1 #Add 1 to counter, for progress \ No newline at end of file diff --git a/main.py b/main.py index 0edee33a48a27cb89a25538b3d5b05ce78857582..8ee5f82f223018149623a092b116283cf6bbb65c 100644 --- a/main.py +++ b/main.py @@ -79,7 +79,7 @@ def home(): return render_template('home.html', builddate=builddate, domain=domain_prepared, snackbar="Please enter a short name, before submitting this form", long_url_prefilled=request.form.get('url'), short_url_prefilled=request.form.get('short').lower(), domain_prefilled=domain_to_index[request.form.get('domain')]) #return the user the prefilled form with an error message, because no short link was provided shorturl = (request.form.get('domain') + "/" + request.form.get('short')).lower() - url = str.encode(request.form.get('url')) + url = request.form.get('url') with sqlite3.connect('db/urls.db') as conn: #Check if another user already used the short link cursor = conn.cursor() res = cursor.execute('SELECT LONG_URL FROM WEB_URL WHERE SHORT_URL=?', [shorturl])