Refactors the API to run using dispatch instead of decorate

The API was never made an object since I couldn't find a way or working around the Flask decorators.

By using dispatch we can get around the issues in #14 and will be able to create better mocks for the API
This commit is contained in:
Sergi Delgado Segura
2019-12-17 17:04:57 +01:00
parent 6129ae9b25
commit 531523c534
3 changed files with 138 additions and 142 deletions

View File

@@ -5,7 +5,7 @@ from time import sleep
from threading import Thread
from cryptography.hazmat.primitives import serialization
from pisa.api import start_api
from pisa.api import API
from pisa.watcher import Watcher
from pisa.tools import bitcoin_cli
from pisa import HOST, PORT, c_logger
@@ -40,7 +40,7 @@ def run_api(db_manager):
)
watcher = Watcher(db_manager, sk_der)
api_thread = Thread(target=start_api, args=[watcher])
api_thread = Thread(target=API(watcher).start)
api_thread.daemon = True
api_thread.start()