Uses a Javascript QR scanner
This commit is contained in:
parent
6e88c25339
commit
6c9b5169d2
6
main.py
6
main.py
@ -3,7 +3,7 @@
|
||||
import uuid
|
||||
import sqlite3
|
||||
from datetime import datetime
|
||||
from flask import Flask, request, render_template
|
||||
from flask import Flask, request, render_template, current_app
|
||||
from flask_uuid import FlaskUUID
|
||||
from flask_qrcode import QRcode
|
||||
from flask_socketio import SocketIO, emit
|
||||
@ -49,6 +49,10 @@ def show_qr_and_list():
|
||||
|
||||
return render_template("template.html")
|
||||
|
||||
@app.route('/scan')
|
||||
def show_qr_reader():
|
||||
return current_app.send_static_file('scan.html')
|
||||
|
||||
@app.route('/<uuid:id>/<hashed>')
|
||||
def catch_uuids(id, hashed):
|
||||
user = request.headers.get('Remote-User')
|
||||
|
||||
48
static/instascan.min.js
vendored
Normal file
48
static/instascan.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
33
static/scan.html
Normal file
33
static/scan.html
Normal file
@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Instascan</title>
|
||||
<!-- script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script -->
|
||||
<!-- script src="https://rawgit.com/schmich/instascan-builds/master/instascan.min.js"></script -->
|
||||
<script src="/static/instascan.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<video style="outline:none; width:90%;" id="preview"></video>
|
||||
<script type="text/javascript">
|
||||
let options = {
|
||||
video: document.getElementById('preview'),
|
||||
mirror: false,
|
||||
};
|
||||
let scanner = new Instascan.Scanner(options);
|
||||
scanner.addListener('scan', function (content) {
|
||||
window.location.replace(content);
|
||||
});
|
||||
Instascan.Camera.getCameras().then(function (cameras) {
|
||||
if (cameras.length > 1) {
|
||||
scanner.start(cameras[1]);
|
||||
} else if (cameras.length > 0) {
|
||||
scanner.start(cameras[0]);
|
||||
} else {
|
||||
console.error('No cameras found.');
|
||||
}
|
||||
}).catch(function (e) {
|
||||
console.error(e);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue
Block a user