Skip to main content
Sign in
Snippets Groups Projects
Commit 7273a42a authored by Jonas Leder's avatar Jonas Leder
Browse files

added QR code and preview of base64 QR

parent bd4ef77e
Branches
Tags
No related merge requests found
...@@ -379,6 +379,17 @@ def api(): ...@@ -379,6 +379,17 @@ def api():
'INSERT INTO WEB_URL (LONG_URL, SHORT_URL, USERNAME) VALUES (?, ?, ?)', 'INSERT INTO WEB_URL (LONG_URL, SHORT_URL, USERNAME) VALUES (?, ?, ?)',
[longURL, short, username] [longURL, short, username]
) )
try:
request.form['qr']
qr64 = "data:image/jpeg;base64," + makeQR(url_scheme + "://" + short)
return jsonify(
status="0",
message="ok",
qr=qr64
)
except:
return jsonify( return jsonify(
status="0", status="0",
message="ok" message="ok"
... ...
......
...@@ -23,15 +23,17 @@ ...@@ -23,15 +23,17 @@
<ul> <ul>
<li>short: the short URL you want to get. example: {{domain}}/example</li> <li>short: the short URL you want to get. example: {{domain}}/example</li>
<li>long: the long URL you want to short</li> <li>long: the long URL you want to short</li>
<li>qr: if you add this parameter you will get an base64 encoded QR code image</li>
<li>apikey: you can add this argument, if you want to assign this link to your account.</li> <li>apikey: you can add this argument, if you want to assign this link to your account.</li>
</ul> </ul>
<p>example API call with curl: <i>curl -d "apikey={{apikey}}&short={{domain}}/example&long=http://example.com" -X POST {{url_scheme}}://{{domain}}/user/api</i></p> <p>example API call with curl: <i>curl -d "apikey={{apikey}}&short={{domain}}/example&long=http://example.com" -X POST {{url_scheme}}://{{domain}}/user/api</i>
<h3>Responses from Server</h3> <h3>Responses from Server</h3>
<p>The response from the server is always made in json format it includes the following arguments:</p> <p>The response from the server is always made in json format it includes the following arguments:</p>
<ul> <ul>
<li>status: The status code of the reponse. Down there is a table with the posible response codes</li> <li>status: The status code of the reponse. Down there is a table with the posible response codes</li>
<li>message: This argument will do the same like the status code, but it is written out, for reading by human.</li> <li>message: This argument will do the same like the status code, but it is written out, for reading by human.</li>
<li>qr: If you enabled the QR code this will include a QR code of the shorten link as base64 coded jpeg image</li>
</ul> </ul>
<h4>Response codes:</h4> <h4>Response codes:</h4>
...@@ -62,4 +64,15 @@ ...@@ -62,4 +64,15 @@
</tr> </tr>
</table> </table>
<h2>Preview image</h2>
<p>Please paste your base64 image here: <input type="text" id="base64Input"> <button onclick="showBase64Image();">show</button></p>
<p style="font-size: 13px;">(this will not work very well in google Chrome)</p>
<img id="base64Image">
<script>
function showBase64Image(){
document.getElementById("base64Image").src = document.getElementById("base64Input").value;
}
</script>
</body> </body>
\ 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