exit() __version__ = "0.0" from flask import Flask as wserv app = wserv('superTinySearch API Runtime') from flask import render_template import sys debugmode = False if "debug" in sys.argv: debugmode = True del sys def makeServerHeader(): import sys return f"superTinySearch API/{__version__} (Unix) (Python v{sys.version})" # @app.errorhandler(404) # def not_found(error): # from flask import request as rq # if rq.args.get('returnFormat','') == "xml" @app.route("/") def noHumans(): from flask import Response resp = Response(response="running", status=200, mimetype="text/plain") resp.headers["Server"] = makeServerHeader resp.headers["Accept"] = "text/plain" return resp @app.route("/about") def aboutThis(): from flask import Response resp = Response(response=f"superTinySearch API v{__version__}", status=200, mimetype="text/plain") resp.headers["Server"] = makeServerHeader resp.headers["Accept"] = "text/plain" return resp @app.route("/apifront?returnFormat=&srcHostname=", methods=['GET', 'POST']) def apiRun(rf='xml', src=None): from flask import request as rq if rq.method == 'GET': return 'GET REQUESTS NOT ALLOWED' else: from src import frontend out = frontend.parsePOST(rq.form.to_dict(flat=False), rf, src) del frontend from flask import Response resp = Response(response=out.content, status=500, mime="text/plain") if rf == "xml": resp.headers["Content-Type"] = "text/xml; charset=utf-8" elif rf == "json": resp.headers["Content-Type"] = "application/json; charset=utf-8" else: resp.headers["Content-Type"] = "text/plain; charset=utf-8" resp.headers["Server"] = makeServerHeader() resp.status = 200 return resp if __name__ == '__main__': app.run(host="0.0.0.0", port=443) else: raise "INVALID USAGE OF API APP"