a hell lot

you dont know
This commit is contained in:
lda committed 2024-07-14 03:58:44 +07:00
1 parent 28bf714147
commit 853dd7871d
3 files changed
+100 -47

No files matched your search

+90 -47
View File
@@ -1,10 +1,12 @@
import http.server as qqq
import mysql.connector as ee2
import json
import datetime
import os
# import datetime
# import os
from dotenv import dotenv_values
from typing import Callable, Dict, Any
# from typing import Callable, Dict, Any
from things import (
funny_trycatch_wrapper,
@@ -62,7 +64,7 @@ def get_that_connection(
class ServerLogic(qqq.BaseHTTPRequestHandler):
def close2(self):
def __close2(self):
try:
self.server.server_close()
except BaseException as e:
@@ -71,6 +73,9 @@ class ServerLogic(qqq.BaseHTTPRequestHandler):
print("gato")
raise SystemExit("truly the /close")
def youJustHaveToDoTheseStuff(self):
print(self.headers, "hd")
def close(self):
funny_trycatch_wrapper(
tries=[(self.server.server_close)],
@@ -86,7 +91,7 @@ class ServerLogic(qqq.BaseHTTPRequestHandler):
self.send_header(key, headers[key]) # why!
self.end_headers()
def do_GET2(self):
def __do_GET2(self):
if self.path == "/close":
return self.close()
@@ -108,26 +113,47 @@ class ServerLogic(qqq.BaseHTTPRequestHandler):
return
def do_GET(self):
self.youJustHaveToDoTheseStuff()
if self.path == "/close":
return self.close()
elif self.path == "/endp":
if self.path == "/":
self.header_setup()
with open("index.html", "rb") as file:
self.wfile.write(file.read())
return
(connectio, eror) = get_that_connection(connectionSettings)
if eror:
print("coneti eror: ", eror)
return
with connectio.cursor(buffered=True) as cur:
try:
res = cur.execute("select * from tbale")
w = cur.fetchall()
except Exception as e:
print(e)
return # return ealy no else
if self.path == "/endp":
self.header_setup(200, {"Content-type": "application/json"})
(connectio, eror) = get_that_connection(connectionSettings)
if eror:
print("coneti eror: ", eror)
return
c = process_tuples(w)
print(w, c, sep="\n")
self.wfile.write(str(c).encode())
return
else:
with connectio.cursor(buffered=True) as cur:
try:
res = cur.execute("select * from tbale")
w = cur.fetchall()
res = cur.execute("select neme, kewod from tbale")
wd = cur.fetchall()
except Exception as e:
print(e)
return # return ealy no else
c = process_tuples(w)
print(w, c, sep="\n")
self.wfile.write(str(c).encode())
return
else:
# print(wd)
for a, v in wd:
# print(a,v)
# print(self.path, a)
if self.path.strip("/") == a:
self.header_setup(200)
self.wfile.write(v.encode())
return
self.header_setup(404)
self.wfile.write(
b"""
@@ -137,7 +163,7 @@ class ServerLogic(qqq.BaseHTTPRequestHandler):
)
return
def do_POST2(self):
def __do_POST2(self):
if self.path == "/close":
return self.close()
self.header_setup()
@@ -183,50 +209,67 @@ class ServerLogic(qqq.BaseHTTPRequestHandler):
return
def do_POST(self):
self.youJustHaveToDoTheseStuff()
match self.path:
case "/close":
return self.close()
case "/endp":
self.header_setup()
content_type = self.headers.get("Content-Type")
content_length = int(self.headers["Content-Length"])
with self.rfile as r:
post_data_bytes = self.rfile.read(content_length)
post_data_bytes = r.read(content_length)
## read how many bytes is the content length
self.wfile.write(
b"MY SERVER: The post data I received from the request has following data:\n"
b"Ive got a POST at "
+ self.headers["Origin"].encode()
+ b" from "
+ self.headers["Referer"].encode()
+ b" with the following data:\n"
+ post_data_bytes
)
try:
data_dict: dict = json.loads(post_data_bytes.decode("utf-8"))
except Exception as e:
print(e)
(connectio, eror) = get_that_connection(connectionSettings)
if eror:
print("coneti eror: ", eror)
self.wfile.write(
b"the thing cant even start like what f: " + str(eror).encode()
)
return
print((*data_dict.keys(), *data_dict.values()))
with connectio.cursor(prepared=True) as cur:
if content_type == "application/json":
try:
res = cur.execute(
"insert into tbale (kewod, expi) values (?, ?);",
(data_dict["kewod"],data_dict["expi"],),
multi=True,
)
print(res)
data_dict: dict = json.loads(post_data_bytes.decode("utf-8"))
except Exception as e:
print("execute err: ", e)
print(e)
(connectio, eror) = get_that_connection(connectionSettings)
if eror:
print("coneti eror: ", eror)
self.wfile.write(
b"\n is it very much Invalid: " + str(e).encode()
b"the thing cant even start like what f: "
+ str(eror).encode()
)
else:
print(cur)
cur.execute("select * from tbale")
self.wfile.write(b"\n We have this in the this: ")
self.do_GET()
return
print((*data_dict.keys(), *data_dict.values()))
with connectio.cursor(prepared=True) as cur:
try:
res = cur.execute(
"insert into tbale (kewod, expi) values (?, ?);",
(
data_dict["kewod"],
data_dict["expi"],
),
multi=True,
)
print(res)
except Exception as e:
print("execute err: ", e)
self.wfile.write(
b"\n is it very much Invalid: " + str(e).encode()
)
else:
print(cur)
cur.execute("select * from tbale")
self.wfile.write(b"\n We have this in the this: ")
self.do_GET()
else:
self.wfile.write(b"\nits of the type: ")
self.wfile.write(content_type.encode())
case _:
self.header_setup(403)
self.wfile.write(
+7
View File
@@ -0,0 +1,7 @@
<form action="/endp" method="post">
<label for="oneid"></label><input type="text" name="one" id="oneid">
<label for="twoid"></label><textarea name="two" id="twoid"></textarea>
<label for="threeid"></label><input type="number" name="three" id="threeid">
<label for="fourid"></label><input type="number" name="four" id="fourid">
<input type="submit" value="Sumit ur font assfuck">
</form>
+3
View File
@@ -0,0 +1,3 @@
# ww
i hate this more than you do