22DevOps Info Service
33Main application module providing system information and health check.
44"""
5+
56import os
6- import socket
77import platform
8- from datetime import datetime , timezone
8+ import socket
9+ from datetime import UTC , datetime
10+
911from flask import Flask , jsonify , request
1012
1113app = Flask (__name__ )
1618DEBUG = os .getenv ('DEBUG' , 'False' ).lower () == 'true'
1719
1820# Application start time for uptime calculation
19- START_TIME = datetime .now (timezone . utc )
21+ START_TIME = datetime .now (UTC )
2022
2123
2224def get_system_info ():
@@ -33,7 +35,7 @@ def get_system_info():
3335
3436def get_uptime ():
3537 """Calculate application uptime."""
36- delta = datetime .now (timezone . utc ) - START_TIME
38+ delta = datetime .now (UTC ) - START_TIME
3739 seconds = int (delta .total_seconds ())
3840 hours = seconds // 3600
3941 minutes = (seconds % 3600 ) // 60
@@ -53,7 +55,7 @@ def get_runtime_info():
5355 return {
5456 'uptime_seconds' : uptime ['seconds' ],
5557 'uptime_human' : uptime ['human' ],
56- 'current_time' : datetime .now (timezone . utc ).isoformat (),
58+ 'current_time' : datetime .now (UTC ).isoformat (),
5759 'timezone' : 'UTC'
5860 }
5961
@@ -118,7 +120,7 @@ def health():
118120 """
119121 response = {
120122 'status' : 'healthy' ,
121- 'timestamp' : datetime .now (timezone . utc ).isoformat (),
123+ 'timestamp' : datetime .now (UTC ).isoformat (),
122124 'uptime_seconds' : get_uptime ()['seconds' ]
123125 }
124126
0 commit comments