From 2528a362787711421899f7edf45fd02e26dd0ed4 Mon Sep 17 00:00:00 2001 From: Ubergeek Date: Wed, 22 Jan 2020 13:29:15 -0500 Subject: [PATCH] Initial api commit --- thunix_api.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 thunix_api.py diff --git a/thunix_api.py b/thunix_api.py new file mode 100644 index 0000000..a0841fb --- /dev/null +++ b/thunix_api.py @@ -0,0 +1,40 @@ +# thunix_api.py +import flask + +from flask import Flask, request, jsonify +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" + app.run() + +# teapot +@app.route("/teapot") +def teapot(): + teapot = [ +{ + "tea" : "available", + "height" : "short", + "width" : "stout" +} +] + return jsonify(teapot) + app.run() + +# main loop +if __name__ == "__main__": # on running python app.py + app.run() # run the flask app