Skip to content

Hit the web server for logging. #1

@boomalator

Description

@boomalator

I want to have the door system call a Web URL when a card is granted or denied access. I think that two lines of code should do it, plus whatever is need to load the library.
Both would go in server/init.py

One right after line 115
self.log.info("%s[%s] entered the space" % (card["owner"], card['serial']))

The other right after line 112
self.log.warn("%s[%s] denied access" % (card["owner"], card['serial']))

On the Pi side, the pi doesn't care about the results. It's really just a notification to the server.

It looks like urllib would do it
https://www.learn2crack.com/2014/03/raspberry-pi-post-get.html

But I hear a lot of people recommending requests instead:
https://stackoverflow.com/questions/4476373/simple-url-get-post-function-in-python
http://docs.python-requests.org/en/latest/user/quickstart/#more-complicated-post-requests

It might be worth, "standardizing" (as much as we ever standardize on anything at PS) as we may later want to use POST or HTTPS, and requests is more likely to do that, maybe?

The URL to hit will be:
http://my.protospace.ca/locks/door/108A/1234567890/REFUSED or
http://my.protospace.ca/locks/door/108A/1234567890/ALLOWED

The part up to http://my.protospace.ca/locks/door/108A/ is fixed.

The next section (1234567890) is the RFID card, called "serial" in the door database. It's 10 hex digits (exactly 10).

The final part (REFUSED or ALLOWED) tells whether the card was accepted or rejected.

It wouldn't hurt include a third option for "UNKNOWN" (Unknown cards are also rejected, rejected means we know who you are and don't let you in. In geek terms, Unknowns are not authenticated nor authorized. Rejections are authenticated, but not authorized.)

Let me know what you think, and if you agree, clone the file and have at it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions