More fleshing it out

This commit is contained in:
Ubergeek 2020-01-22 14:28:44 -05:00
parent dcf51fb12f
commit 860f78f206
1 changed files with 23 additions and 12 deletions

View File

@ -2,39 +2,50 @@
import flask import flask
from flask import Flask, request, jsonify from flask import Flask, request, jsonify
import psutil, datetime
app = Flask(__name__) app = Flask(__name__)
# No endpoint selected # No endpoint selected
@app.route("/") @app.route("/")
def home(): def home():
return "The Thunix API. Please see https://wiki.thunix.net/wiki/api for more information." return "The Thunix API. Please see https://wiki.thunix.net/wiki/api for more information."
app.run() app.run()
# ip_info # ip_info
@app.route("/ip_info") @app.route("/ip_info")
def ip_info(): def ip_info():
return "IP Info" return "IP Info"
app.run() app.run()
# uptime # uptime
@app.route("/uptime") @app.route("/uptime")
def uptime(): def uptime():
return "Uptime"
return str(datetime.timedelta(seconds=psutil.boot_time()))
app.run() app.run()
# teapot # teapot
@app.route("/teapot") @app.route("/teapot")
def teapot(): def teapot():
teapot = [ teapots = [
{ {
"tea" : "available", "tea": "available",
"height" : "short", "height": "short",
"width" : "stout" "width": "stout"
} }
] ]
return jsonify(teapot) return jsonify(teapots)
app.run() app.run()
# main loop # main loop
if __name__ == "__main__": # on running python app.py if __name__ == "__main__": # on running python app.py
app.run() # run the flask app app.run() # run the flask app