Skip to content

Instantly share code, notes, and snippets.

@WonRhee
WonRhee / model_relation_ex.py
Created April 17, 2021 04:49 — forked from kirang89/model_relation_ex.py
Example for many-to-many relationship with extra columns in SQLAlchemy
import sqlalchemy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import sessionmaker, relationship
engine = sqlalchemy.create_engine('sqlite:///:memory:')
Base = declarative_base()
@WonRhee
WonRhee / Native app communication
Created May 26, 2019 05:56 — forked from NielsLeenheer/Native app communication
How a web app running on HTTPS can communicatie with local services
I have a web app that needs to talk to point of sale hardware: receipt printers, customer displays,
cash drawers and payment terminals. Direct communication from the web app with these devices is
impossible, so I created a native app that can be installed on the computer that can talk to the
devices. The app runs a web server that exposes these devices using a REST api.
The native app registers itself upon startup with a webservice. It sends its own IP address on
the local network and the server also sees the external IP address of the network. The web app
sends a discovery request to the webservice and it receives all the local IP addresses which
have the same external IP address.