mirror of
https://github.com/simon987/od-database.git
synced 2025-04-19 18:36:44 +00:00
Added API commands
This commit is contained in:
parent
55a0fde19d
commit
73afebec28
40
app.py
40
app.py
@ -628,7 +628,7 @@ def api_add_website():
|
||||
return abort(403)
|
||||
|
||||
|
||||
@app.route("/api/task/enqueue", methods=["POST"])
|
||||
@app.route("/api/task/force_enqueue", methods=["POST"])
|
||||
def api_task_enqueue():
|
||||
try:
|
||||
token = request.json["token"]
|
||||
@ -652,5 +652,43 @@ def api_task_enqueue():
|
||||
return abort(403)
|
||||
|
||||
|
||||
@app.route("/api/task/try_enqueue", methods=["POST"])
|
||||
def api_task_try_enqueue():
|
||||
try:
|
||||
token = request.form.get("token")
|
||||
url = request.form.get("url")
|
||||
except KeyError:
|
||||
return abort(400)
|
||||
|
||||
name = db.check_api_token(token)
|
||||
|
||||
if name:
|
||||
|
||||
message, result = try_enqueue(url)
|
||||
|
||||
return json.dumps({
|
||||
"message": message,
|
||||
"result": result
|
||||
})
|
||||
else:
|
||||
return abort(403)
|
||||
|
||||
|
||||
@app.route("/api/website/random")
|
||||
def api_random_website():
|
||||
|
||||
try:
|
||||
token = request.json["token"]
|
||||
except KeyError:
|
||||
return abort(400)
|
||||
|
||||
name = db.check_api_token(token)
|
||||
|
||||
if name:
|
||||
return str(db.get_random_website_id())
|
||||
else:
|
||||
return abort(403)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run("0.0.0.0", port=12345, threaded=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user