mirror of
https://git.wownero.com/wowlet/wowlet-backend.git
synced 2024-08-15 01:03:13 +00:00
23d594bcd4
Signed-off-by: dsc <dsc@xmr.pm>
82 lines
3.2 KiB
Python
82 lines
3.2 KiB
Python
# SPDX-License-Identifier: BSD-3-Clause
|
|
# Copyright (c) 2020, The Monero Project.
|
|
# Copyright (c) 2020, dsc@xmr.pm
|
|
|
|
import json
|
|
import asyncio
|
|
|
|
from quart import Quart
|
|
from quart_session import Session
|
|
import aioredis
|
|
|
|
import settings
|
|
|
|
app = None
|
|
cache = None
|
|
connected_websockets = set()
|
|
api_data = {}
|
|
nodes = {}
|
|
user_agents = None
|
|
txfiatdb = None
|
|
|
|
print("""\033[91m
|
|
█████▒▓█████ ▄▄▄ ▄▄▄█████▓ ██░ ██ ▓█████ ██▀███
|
|
▓██ ▒ ▓█ ▀▒████▄ ▓ ██▒ ▓▒▓██░ ██▒▓█ ▀ ▓██ ▒ ██▒
|
|
▒████ ░ ▒███ ▒██ ▀█▄ ▒ ▓██░ ▒░▒██▀▀██░▒███ ▓██ ░▄█ ▒
|
|
░▓█▒ ░ ▒▓█ ▄░██▄▄▄▄██░ ▓██▓ ░ ░▓█ ░██ ▒▓█ ▄ ▒██▀▀█▄
|
|
░▒█░ ░▒████▒▓█ ▓██▒ ▒██▒ ░ ░▓█▒░██▓░▒████▒░██▓ ▒██▒
|
|
▒ ░ ░░ ▒░ ░▒▒ ▓▒█░ ▒ ░░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
|
|
░ ░ ░ ░ ▒ ▒▒ ░ ░ ▒ ░▒░ ░ ░ ░ ░ ░▒ ░ ▒░
|
|
░ ░ ░ ░ ▒ ░ ░ ░░ ░ ░ ░░ ░
|
|
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ \033[0m
|
|
""".strip())
|
|
|
|
|
|
async def _setup_cache(app: Quart):
|
|
global cache
|
|
data = {
|
|
"address": "redis://localhost"
|
|
}
|
|
|
|
if settings.redis_password:
|
|
data['password'] = settings.redis_password
|
|
|
|
cache = await aioredis.create_redis_pool(**data)
|
|
app.config['SESSION_TYPE'] = 'redis'
|
|
app.config['SESSION_REDIS'] = cache
|
|
Session(app)
|
|
|
|
|
|
def create_app():
|
|
global app
|
|
app = Quart(__name__)
|
|
|
|
@app.before_serving
|
|
async def startup():
|
|
global nodes, txfiatdb, user_agents
|
|
await _setup_cache(app)
|
|
loop = asyncio.get_event_loop()
|
|
|
|
f = open("data/nodes.json", "r")
|
|
nodes = json.loads(f.read())
|
|
f.close()
|
|
|
|
f = open("data/user_agents.txt", "r")
|
|
user_agents = [l.strip() for l in f.readlines() if l.strip()]
|
|
f.close()
|
|
|
|
from fapi.fapi import FeatherApi
|
|
from fapi.utils import loopyloop, TxFiatDb, XmrRig
|
|
txfiatdb = TxFiatDb(settings.crypto_name, settings.crypto_block_date_start)
|
|
loop.create_task(loopyloop(20, FeatherApi.xmrto_rates, FeatherApi.after_xmrto))
|
|
loop.create_task(loopyloop(120, FeatherApi.crypto_rates, FeatherApi.after_crypto))
|
|
loop.create_task(loopyloop(600, FeatherApi.fiat_rates, FeatherApi.after_fiat))
|
|
loop.create_task(loopyloop(300, FeatherApi.ccs, FeatherApi.after_ccs))
|
|
loop.create_task(loopyloop(900, FeatherApi.reddit, FeatherApi.after_reddit))
|
|
loop.create_task(loopyloop(60, FeatherApi.blockheight, FeatherApi.after_blockheight))
|
|
loop.create_task(loopyloop(60, FeatherApi.check_nodes, FeatherApi.after_check_nodes))
|
|
loop.create_task(loopyloop(43200, txfiatdb.update))
|
|
loop.create_task(loopyloop(43200, XmrRig.releases, XmrRig.after_releases))
|
|
import fapi.routes
|
|
|
|
return app
|