From 860f78f20679023d857f1347866d3cf7505f4717 Mon Sep 17 00:00:00 2001 From: Ubergeek Date: Wed, 22 Jan 2020 14:28:44 -0500 Subject: [PATCH] More fleshing it out --- thunix_api.py | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/thunix_api.py b/thunix_api.py index a0841fb..8711dd0 100644 --- a/thunix_api.py +++ b/thunix_api.py @@ -2,39 +2,50 @@ import flask from flask import Flask, request, jsonify + +import psutil, datetime + + app = Flask(__name__) + # No endpoint selected @app.route("/") def home(): return "The Thunix API. Please see https://wiki.thunix.net/wiki/api for more information." app.run() + # ip_info @app.route("/ip_info") def ip_info(): return "IP Info" app.run() + # uptime @app.route("/uptime") def uptime(): - return "Uptime" + + return str(datetime.timedelta(seconds=psutil.boot_time())) app.run() + # teapot @app.route("/teapot") def teapot(): - teapot = [ -{ - "tea" : "available", - "height" : "short", - "width" : "stout" -} -] - return jsonify(teapot) - app.run() + teapots = [ + { + "tea": "available", + "height": "short", + "width": "stout" + } + ] + return jsonify(teapots) + app.run() + # main loop -if __name__ == "__main__": # on running python app.py - app.run() # run the flask app +if __name__ == "__main__": # on running python app.py + app.run() # run the flask app +