nexus3rd commited on
Commit
76c52cb
·
1 Parent(s): 32455f4
Files changed (2) hide show
  1. app.py +0 -38
  2. templates/index.html +0 -12
app.py CHANGED
@@ -43,44 +43,6 @@ def get_ngrok_tunnels():
43
 
44
  return endpoints
45
 
46
- def get_ngrok_usage():
47
- api_key = os.getenv("NGROK_API_KEY")
48
- if not api_key:
49
- raise HTTPException(status_code=500, detail="Ngrok API key not found.")
50
-
51
- headers = {
52
- "Authorization": f"Bearer {api_key}",
53
- "Ngrok-Version": "2"
54
- }
55
-
56
- try:
57
- response = requests.get("https://api.ngrok.com/account", headers=headers)
58
- response.raise_for_status()
59
- account_data = response.json()
60
- logging.debug("Ngrok account data: %s", account_data)
61
-
62
- usage = account_data.get("usage", {})
63
-
64
- # Ensure keys are available; handle gracefully if not
65
- return {
66
- "month_start": usage.get("month_start", "N/A"),
67
- "month_end": usage.get("month_end", "N/A"),
68
- "total": usage.get("total", 0),
69
- "used": usage.get("used", 0)
70
- }
71
-
72
- except requests.RequestException as e:
73
- logging.error("Request failed: %s", str(e))
74
- raise HTTPException(status_code=500, detail=str(e))
75
- except KeyError as e:
76
- logging.error("Key error: %s", str(e))
77
- return {
78
- "month_start": "N/A",
79
- "month_end": "N/A",
80
- "total": 0,
81
- "used": 0
82
- }
83
-
84
  @app.get("/", response_class=HTMLResponse)
85
  async def read_root(request: Request):
86
  endpoints = get_ngrok_tunnels()
 
43
 
44
  return endpoints
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  @app.get("/", response_class=HTMLResponse)
47
  async def read_root(request: Request):
48
  endpoints = get_ngrok_tunnels()
templates/index.html CHANGED
@@ -4,7 +4,6 @@
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Ngrok Endpoints</title>
7
- <link href="/static/css/output.css" rel="stylesheet">
8
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
9
  <script>
10
  function copyToClipboard(text) {
@@ -92,17 +91,6 @@
92
  </div>
93
  </div>
94
  </div>
95
-
96
- <h2>Account Usage</h2>
97
- <div class="usage">
98
- {% if usage %}
99
- <p>Used: {{ usage.used }} / Total: {{ usage.total }}</p>
100
- <p>Remaining: {{ usage.total - usage.used }}</p>
101
- <p>Percentage Used: {{ (usage.used / usage.total) * 100 }}%</p>
102
- {% else %}
103
- <p>No usage data available.</p>
104
- {% endif %}
105
- </div>
106
 
107
  <!-- Notification -->
108
  <div id="notification"
 
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Ngrok Endpoints</title>
 
7
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
8
  <script>
9
  function copyToClipboard(text) {
 
91
  </div>
92
  </div>
93
  </div>
 
 
 
 
 
 
 
 
 
 
 
94
 
95
  <!-- Notification -->
96
  <div id="notification"