forked from openwallet-foundation-labs/PyDentity-Wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (29 loc) · 1.11 KB
/
main.py
File metadata and controls
36 lines (29 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import ngrok
from dotenv import load_dotenv
from qrcode import QRCode
from app import create_app
from app.plugins import AskarStorage
from asyncio import run as _await
app = create_app()
if __name__ == "__main__":
load_dotenv()
# Only initialize in the child process (when WERKZEUG_RUN_MAIN is set)
if os.environ.get('WERKZEUG_RUN_MAIN'):
# Initialize storage once at startup
_await(AskarStorage().provision(recreate=False))
if os.getenv("NGROK_AUTHTOKEN", None):
try:
listener = ngrok.forward(
5000,
authtoken=os.getenv("NGROK_AUTHTOKEN"),
domain=os.getenv("PYDENTITY_WALLET_DOMAIN")
)
# Store ngrok URL in app config
app.config['NGROK_URL'] = listener.url()
qr = QRCode(box_size=10, border=4)
qr.add_data(listener.url())
qr.print_ascii()
except ValueError:
pass
app.run(host="0.0.0.0", port="5000", debug=True, use_reloader=True)