mirror of
https://github.com/ThunixdotNet/thunix_api.git
synced 2026-06-24 10:59:24 +00:00
Refractor thunix_api to use flask_rest package
This commit is contained in:
19
endpoints/uptime.py
Normal file
19
endpoints/uptime.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from flask_restful import Resource
|
||||
import datetime
|
||||
|
||||
class Uptime(Resource):
|
||||
def get(self):
|
||||
with open("/proc/uptime", "r") as f:
|
||||
secs = float(f.readline().split()[0])
|
||||
delta = datetime.timedelta(seconds=secs)
|
||||
|
||||
payload = [
|
||||
{
|
||||
"days": delta.days,
|
||||
"hours": delta.seconds // 3600,
|
||||
"minutes": delta.seconds // 60,
|
||||
"seconds": delta.seconds
|
||||
}
|
||||
]
|
||||
|
||||
return payload
|
||||
Reference in New Issue
Block a user