stuff
This commit is contained in:
parent
af8e618f01
commit
7589408812
2 changed files with 63 additions and 48 deletions
22
main.py
22
main.py
|
@ -9,27 +9,28 @@ 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 = Response(response="running", status=200, mimetype="text/plain")
|
||||
resp.headers["Server"] = makeServerHeader
|
||||
resp.headers["Accept"] = "text/plain"
|
||||
return resp
|
||||
|
@ -38,16 +39,16 @@ def noHumans():
|
|||
@app.route("/about")
|
||||
def aboutThis():
|
||||
from flask import Response
|
||||
resp=Response(
|
||||
response=f"superTinySearch API v{__version__}",
|
||||
resp = Response(response=f"superTinySearch API v{__version__}",
|
||||
status=200,
|
||||
mimetype="text/plain"
|
||||
)
|
||||
mimetype="text/plain")
|
||||
resp.headers["Server"] = makeServerHeader
|
||||
resp.headers["Accept"] = "text/plain"
|
||||
return resp
|
||||
|
||||
@app.route("/apifront?returnFormat=<rf>&srcHostname=<src>", methods=['GET','POST'])
|
||||
|
||||
@app.route("/apifront?returnFormat=<rf>&srcHostname=<src>",
|
||||
methods=['GET', 'POST'])
|
||||
def apiRun(rf='xml', src=None):
|
||||
from flask import request as rq
|
||||
if rq.method == 'GET':
|
||||
|
@ -68,6 +69,7 @@ def apiRun(rf = 'xml', src = None):
|
|||
resp.status = 200
|
||||
return resp
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host="0.0.0.0", port=443)
|
||||
else:
|
||||
|
|
|
@ -40,7 +40,20 @@ class Accessor:
|
|||
""")
|
||||
self.buffers.db.commit()
|
||||
return True
|
||||
def removeEntry(self, filters):
|
||||
if self.mode == "ro":
|
||||
raise ImportError
|
||||
self._refresh()
|
||||
query="DELETE FROM index WHERE "
|
||||
if filters.full:
|
||||
query+=f"fullURL = {filters.fullURL}"
|
||||
elif filters.hostname:
|
||||
query+=f"fullURL LIKE %{filters.hostname}%"
|
||||
|
||||
query+=";"
|
||||
self.buffers.dbcursor.execute(query)
|
||||
self.buffers.db.commit()
|
||||
return True
|
||||
def __init__(self, mode="ro"):
|
||||
self.mode = mode
|
||||
self.search = {'query': None, 'limit': 20, 'offset': 0}
|
||||
|
|
Loading…
Reference in a new issue