annotate console/console.py @ 5:5a99bde7a506

stub py service for console
author drewp@bigasterisk.com
date Mon, 13 Mar 2023 18:52:00 -0700
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
1
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
2 import logging
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
3 import os
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
4 import socket
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
5 import sys
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
6
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
7 import uvicorn
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
8 from prometheus_client import Gauge
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
9 from starlette.applications import Starlette
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
10 from starlette.requests import Request
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
11 from starlette.responses import HTMLResponse
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
12 from starlette.routing import Mount
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
13 from starlette.staticfiles import StaticFiles
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
14 from starlette_exporter import PrometheusMiddleware, handle_metrics
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
15
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
16
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
17
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
18
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
19 def main():
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
20 app = Starlette(debug=True,
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
21 routes=[
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
22 # Mount('/', app=StaticFiles(directory='.'), name="static"),
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
23 ],
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
24 )
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
25
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
26 app.add_middleware(PrometheusMiddleware, app_name='racc_console')
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
27 app.add_route("/metrics", handle_metrics)
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
28 uvicorn.run(app, host='0.0.0.0', port=8000)
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
29
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
30
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
31 if __name__ == "__main__":
5a99bde7a506 stub py service for console
drewp@bigasterisk.com
parents:
diff changeset
32 main()