I am building a link shortening service using Flask and SQLite. The shortening part is done , but I am having issues calling the actual URL from the SQLite db.
Here's my table:
CREATE TABLE WEB_URL(
ID INTEGER PRIMARY KEY AUTOINCREMENT,
URL TEXT ,
S_URL TEXT ,
COUNTER INT DEFAULT 0
);
And the get redirect function is :
@app.route('/<short_url>')
def redirect(short_url):
conn = sqlite3.connect('url.db')
cursor = conn.cursor()
select_row = '''
SELECT URL FROM WEB_URL WHERE S_URL = %s
'''%(short_url)
result_cur = cursor.execute(select_row)
try:
redirect_url = result_cur.fetchnone()[0]
conn.commit()
conn.close()
return redirect(redirect_url)
except Exception as e:
error = e
return render_template('index.html' , error = error)
It's throwing an operational error:
result_cur = cursor.execute(select_row)
OperationalError: no such column: favicon.ico
Now I have never ever mentioned favicon.ico in my code. What am I doing wrong ? Thanks!