mirror of
https://github.com/logos-blockchain/logos-blockchain-block-explorer-template.git
synced 2026-04-03 09:23:07 +00:00
43 lines
899 B
Python
43 lines
899 B
Python
import asyncio
|
||
from os import getenv
|
||
|
||
import uvicorn
|
||
from dotenv import load_dotenv
|
||
|
||
from app import create_app
|
||
from logs import setup_logging
|
||
|
||
|
||
async def main():
|
||
base_path = getenv("NBE_BASE_PATH", "").strip().rstrip("/")
|
||
app = create_app(base_path)
|
||
|
||
host = getenv("NBE_HOST", "0.0.0.0")
|
||
port = int(getenv("NBE_PORT", 8000))
|
||
config = uvicorn.Config(
|
||
app,
|
||
host=host,
|
||
port=port,
|
||
reload=False,
|
||
loop="asyncio",
|
||
log_config=None,
|
||
)
|
||
server = uvicorn.Server(config)
|
||
|
||
try:
|
||
await server.serve()
|
||
except KeyboardInterrupt:
|
||
# Swallow debugger’s SIGINT
|
||
pass
|
||
|
||
|
||
# Pycharm-Debuggable Uvicorn Server
|
||
if __name__ == "__main__":
|
||
try:
|
||
load_dotenv()
|
||
setup_logging()
|
||
asyncio.run(main())
|
||
except KeyboardInterrupt:
|
||
# Graceful stop triggered by debugger/CTRL-C
|
||
pass
|