Skip to content

Commit

Permalink
Fix operation on Google Chrome (add CORS support + change documentati…
Browse files Browse the repository at this point in the history
…on on opening client-side websocket)
  • Loading branch information
Kurocon committed Aug 21, 2022
1 parent 07f6b78 commit d4d5d90
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 28 deletions.
23 changes: 1 addition & 22 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

Expand Down
8 changes: 4 additions & 4 deletions juliana.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]"
Expand Down Expand Up @@ -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 = []
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d4d5d90

Please sign in to comment.