updated several things
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
from flask import Flask
|
||||
from flask import request
|
||||
from flask_cors import CORS
|
||||
from time import sleep
|
||||
from settings import token, get_connection_ban_detector
|
||||
|
||||
app = Flask(__name__)
|
||||
@@ -25,14 +26,33 @@ def get_answer():
|
||||
with get_connection_ban_detector() as conn:
|
||||
with conn.cursor(buffered=True) as cur: #wtf is this buffered shit even
|
||||
sql_statement = """
|
||||
INSERT IGNORE INTO ban_detector.ban_detector (fingerprint, ip) VALUES (%s, %s);
|
||||
UPDATE ban_detector.ban_detector x
|
||||
SET fingerprint = %s,
|
||||
modified_on = now()
|
||||
WHERE
|
||||
x.ip = %s
|
||||
and
|
||||
x.last_connect = (select last_connect
|
||||
from ban_detector.ban_detector x1
|
||||
where
|
||||
x1.ip = x.ip
|
||||
order by last_connect desc limit 1);
|
||||
"""
|
||||
cur.execute(sql_statement, [name, ip])
|
||||
crowcount = cur.rowcount
|
||||
conn.commit()
|
||||
conn.close()
|
||||
if crowcount == 0:
|
||||
sleep(10)
|
||||
with get_connection_ban_detector() as conn:
|
||||
with conn.cursor(buffered=True) as cur: #wtf is this buffered shit even
|
||||
cur.execute(sql_statement, [name, ip])
|
||||
conn.commit()
|
||||
conn.close()
|
||||
#print("name: ", name, ' ip: ', ip)
|
||||
print("comitting content: ", content)
|
||||
return ""
|
||||
|
||||
if __name__ == "__main__":
|
||||
from waitress import serve
|
||||
serve(app, host="localhost", port=5085, threads = 8)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user