Move config to separate file
This commit is contained in:
parent
09d19459e1
commit
49daf35a16
27
app.py
27
app.py
|
@ -8,6 +8,11 @@ import json
|
|||
import sys
|
||||
import statistics
|
||||
|
||||
import config
|
||||
|
||||
# Make a dict of config.* to pass to templating
|
||||
conf = {x: getattr(config, x) for x in dir(config) if not x.startswith('__')}
|
||||
|
||||
app = flask.Flask(__name__)
|
||||
# DEBUG:
|
||||
app.config['TEMPLATES_AUTO_RELOAD'] = True
|
||||
|
@ -17,9 +22,7 @@ app.jinja_env.auto_reload = True
|
|||
lmq = pylokimq.LokiMQ(pylokimq.LogLevel.warn)
|
||||
lmq.max_message_size = 10*1024*1024
|
||||
lmq.start()
|
||||
lokid = lmq.connect_remote('ipc://./mainnet.sock')
|
||||
#lokid = lmq.connect_remote('ipc://./testnet.sock')
|
||||
#lokid = lmq.connect_remote('ipc://./devnet.sock')
|
||||
lokid = lmq.connect_remote(config.lokid_rpc)
|
||||
|
||||
cached = {}
|
||||
cached_args = {}
|
||||
|
@ -178,21 +181,9 @@ def main(refresh=None, page=0, per_page=None, first=None, last=None):
|
|||
timestamp=datetime.utcnow(),
|
||||
)
|
||||
|
||||
config = dict(
|
||||
# FIXME: make these configurable
|
||||
pusher=True,
|
||||
key_image_checker=True,
|
||||
output_key_checker=True,
|
||||
autorefresh_option=True,
|
||||
mainnet_url='',
|
||||
testnet_url='',
|
||||
devnet_url='',
|
||||
blocks_per_page=20
|
||||
)
|
||||
|
||||
custom_per_page = ''
|
||||
if per_page is None or per_page <= 0 or per_page > 100:
|
||||
per_page = config['blocks_per_page']
|
||||
if per_page is None or per_page <= 0 or per_page > config.max_blocks_per_page:
|
||||
per_page = config.blocks_per_page
|
||||
else:
|
||||
custom_per_page = '/{}'.format(per_page)
|
||||
|
||||
|
@ -300,6 +291,6 @@ def main(refresh=None, page=0, per_page=None, first=None, last=None):
|
|||
custom_per_page=custom_per_page,
|
||||
mempool=mp,
|
||||
server=server,
|
||||
config=config,
|
||||
config=conf,
|
||||
refresh=refresh,
|
||||
)
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
# LMQ RPC endpoint of lokid; can be a unix socket 'ipc:///path/to/lokid.sock' (preferred) or a tcp
|
||||
# socket 'tcp://127.0.0.1:5678'. Typically you want this running with admin permission.
|
||||
lokid_rpc = 'ipc://./devnet.sock'
|
||||
|
||||
# Default blocks per page for the index.
|
||||
blocks_per_page=20
|
||||
# Maximum blocks per page a user can request
|
||||
max_blocks_per_page=100
|
||||
|
||||
# Some display and/or feature options:
|
||||
pusher=True
|
||||
key_image_checker=True
|
||||
output_key_checker=True
|
||||
autorefresh_option=True
|
||||
|
||||
# URLs to networks other than the one we are on:
|
||||
mainnet_url='https://blocks.lokinet.dev'
|
||||
testnet_url='https://testnet.lokinet.dev'
|
||||
devnet_url='https://devnet.lokinet.dev'
|
||||
|
||||
# Same as above, but these apply if we are on a .loki URL:
|
||||
lokinet_mainnet_url='http://kcpyawm9se7trdbzncimdi5t7st4p5mh9i1mg7gkpuubi4k4ku1y.loki'
|
||||
lokinet_testnet_url='http://testnet.kcpyawm9se7trdbzncimdi5t7st4p5mh9i1mg7gkpuubi4k4ku1y.loki'
|
||||
lokinet_devnet_url='http://devnet.kcpyawm9se7trdbzncimdi5t7st4p5mh9i1mg7gkpuubi4k4ku1y.loki'
|
Loading…
Reference in New Issue