Skip to content
Snippets Groups Projects
Commit d7075cf0 authored by Jonas Leder's avatar Jonas Leder
Browse files

added QR code

parent 7397d9ae
Branches
Tags
No related merge requests found
......@@ -250,7 +250,7 @@ def ownLinks():
try:
entriesList = res.fetchall()
for entries in entriesList: #for every entrie in the database add a line to the table
response = response + "<tr>\n<td>" + entries[0] + "</td>\n<td>" + entries[1] + '</td>\n<td><a id="red" href="/user/delete?link=' + escape(entries[1]) + '">delete</a></tr>\n'
response = response + "<tr>\n<td>" + entries[0] + "</td>\n<td>" + entries[1] + '</td>\n<td><a id="red" href="/user/delete?link=' + escape(entries[1]) + '">delete</a> <a href="#" id="dialog-link" onclick="buttonListener(\'' + entries[1] + '\', this)">QR</a></tr>\n'
response = response + "</table>" #Close the table
if(len(entriesList) == 0): response = 'you have no shorten links. <a href="/">back</a>' #If user has no shorten links make this message with a back button
except:
......@@ -275,6 +275,11 @@ def delete():
except:
abort(500)
@app.route('/user/makeqr')
def makeQrCode():
link = request.args.get('link')
return "data:image/jpeg;base64," + makeQR("http://" + link)
if __name__ == '__main__':
table_check()# This code checks whether database table is created or not
......
......
<!DOCTYPE html>
<html lang="en">
<head>
<link href="/static/jquery-ui.css" rel="stylesheet">
<link href="{{ url_for('static', filename='style.css') }}" rel="stylesheet">
<title>URL shorter</title>
</head>
......@@ -12,5 +13,36 @@
{{content | safe}}
</div>
</div>
<!-- ui-dialog -->
<div id="dialog" title="QRCODE">
<img id="dialogContent" src="">
</div>
<script src="/static/external/jquery/jquery.js"></script>
<script src="/static/jquery-ui.js"></script>
<script>
$( "#dialog" ).dialog({
autoOpen: false
});
// Link to open the dialog
/*$( "#dialog-link" ).click(function( event ) {
document.getElementById("dialogContent").innerText = "xxx"
$( "#dialog" ).dialog( "open" );
event.preventDefault();
});*/
function buttonListener(value){
value = "/user/makeqr?link=" + value
$.get(value, function(data, status){
document.getElementById("dialogContent").src = data;
$( "#dialog" ).dialog( "open" );
setTimeout(function(){
$('#dialog').dialog({width: document.getElementById("dialogContent").width + 35});
}, 1);
});
}
</script>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment