diff --git a/.gitignore b/.gitignore index 0d663b8..24cde00 100644 --- a/.gitignore +++ b/.gitignore @@ -108,30 +108,12 @@ venv.bak/ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 # User-specific stuff: -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/dictionaries - -# Sensitive or high-churn files: -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.xml -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml - -# Gradle: -.idea/**/gradle.xml -.idea/**/libraries +.idea # CMake cmake-build-debug/ cmake-build-release/ -# Mongo Explorer plugin: -.idea/**/mongoSettings.xml - ## File-based project format: *.iws @@ -146,9 +128,6 @@ out/ # JIRA plugin atlassian-ide-plugin.xml -# Cursive Clojure plugin -.idea/replstate.xml - # Crashlytics plugin (for Android Studio and IntelliJ) com_crashlytics_export_strings.xml crashlytics.properties diff --git a/README.md b/README.md index bbcd913..16069ba 100644 --- a/README.md +++ b/README.md @@ -29,14 +29,14 @@ Installeer onder Linux de PC/SC Smart Card daemon ( [PCSClite](https://pcsclite. ### Websocket Vanuit een browser connect je met de WebSocket. - socket = new WebSocket('ws://localhost:3000', 'nfc'); + socket = new WebSocket('ws://localhost:3000'); socket.onmessage = function (event) { var rfid = JSON.parse(event.data); console.log("Tag scanned!"); console.log(rfid); }; -Als er een kaart wordt gescand ontvang je in het 'nfc_read' event een JSON-object met kaartinfo over de socket. +Als er een kaart wordt gescand ontvang je over de websocket een JSON-object (in het veld `event.data` hierboven) met kaartinfo over de socket. {"type": "iso-x", "atqa":"12:34", "uid":"ab:cd:ef:gh", "sak":"56"} diff --git a/juliana.py b/juliana.py index f3accd6..0dc8dc0 100644 --- a/juliana.py +++ b/juliana.py @@ -14,17 +14,16 @@ from subprocess import Popen import smartcard.System -from smartcard.CardConnection import CardConnection -from smartcard.CardConnectionObserver import CardConnectionObserver from smartcard.CardMonitoring import CardMonitor, CardObserver from smartcard.ReaderMonitoring import ReaderMonitor, ReaderObserver from smartcard.Exceptions import CardConnectionException -from flask import Flask, render_template, request +from flask import Flask, request +from flask_cors import CORS from flask_sock import Sock -APP_VERSION = "3.0" +APP_VERSION = "3.1" APP_NAME = "JulianaNFC" APP_AUTHOR = "Kevin Alberts, I.C.T.S.V. Inter-/Actief/" APP_SUPPORT = "www@inter-actief.net" @@ -264,6 +263,7 @@ def update(self, observable, actions): app.debug = False app.config['SECRET_KEY'] = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(20)) sock = Sock(app) +cors = CORS(app, supports_credentials=True) socket_clients = [] diff --git a/requirements.txt b/requirements.txt index e4311f1..cecfa35 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ pyscard>=2.0,<2.1 flask flask-sock>=0.5,<1.0 +flask-cors>=3.0.10,<3.1 wxPython>=4.1.1 plyer>=2.0.0,<2.1