def create_app(): app = Flask(__name__) with app.app_context(): current_app.db_wrapper = DBWrapper(DB_HOST, DB_PORT, DATABASE, DB_USER, DB_PASSWORD) api = Api(app) api.add_resource(Stub, '/stub') api.add_resource(Artist, '/artist', '/artist/<int:artist_id>') api.add_resource(Track, '/track', '/track/<int:track_id>') return app
def create_app(): app = Flask(__name__) _ = CORS(app, resources={r"*": {"origins": "*"}}) with app.app_context(): current_app.db_wrapper = DBWrapper(environ['DB_HOST'], environ['DB_PORT'], environ['DATABASE'], environ['DB_USER'], environ['DB_PASSWORD']) api = Api(app) api.add_resource(Patient, "/patient") api.add_resource(Report, "/report") return app
def __init__(self, plugin, window): """ Window handle setting up the database and file system monitor. """ # defaults self._root = "." # Setup self._window = window self._plugin = plugin self._message_bus = self._window.get_message_bus() self._db = DBWrapper() self._monitor = None self._message_bus.connect('/plugins/filebrowser', 'root_changed', self.root_changed)
# wait for internet connection def connect(host='http://google.com'): try: urllib.request.urlopen(host) #Python 3.x return True except urllib.error.URLError: print('not connected to internet') return False while True: if connect(): break time.sleep(5) db = DBWrapper() COM_PORT = '/dev/ttyACM0' # 指定通訊埠名稱 BAUD_RATES = 9600 # 設定傳輸速率 ser_tgs = serial.Serial(COM_PORT, BAUD_RATES) # 初始化序列通訊埠 # SDS011 import struct from datetime import datetime # Change this to the right port - /dev/tty* on Linux and Mac and COM* on Windows PORT = '/dev/ttyUSB0' UNPACK_PAT = '<ccHHHcc' ser_sds011 = serial.Serial(PORT, 9600, bytesize=8, parity='N', stopbits=1)