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
+65 -12

No files matched your search

+55 -12
View File
@@ -1,10 +1,12 @@
import http.server as qqq import http.server as qqq
import mysql.connector as ee2 import mysql.connector as ee2
import json import json
import datetime
import os # import datetime
# import os
from dotenv import dotenv_values from dotenv import dotenv_values
from typing import Callable, Dict, Any
# from typing import Callable, Dict, Any
from things import ( from things import (
funny_trycatch_wrapper, funny_trycatch_wrapper,
@@ -62,7 +64,7 @@ def get_that_connection(
class ServerLogic(qqq.BaseHTTPRequestHandler): class ServerLogic(qqq.BaseHTTPRequestHandler):
def close2(self): def __close2(self):
try: try:
self.server.server_close() self.server.server_close()
except BaseException as e: except BaseException as e:
@@ -71,6 +73,9 @@ class ServerLogic(qqq.BaseHTTPRequestHandler):
print("gato") print("gato")
raise SystemExit("truly the /close") raise SystemExit("truly the /close")
def youJustHaveToDoTheseStuff(self):
print(self.headers, "hd")
def close(self): def close(self):
funny_trycatch_wrapper( funny_trycatch_wrapper(
tries=[(self.server.server_close)], tries=[(self.server.server_close)],
@@ -86,7 +91,7 @@ class ServerLogic(qqq.BaseHTTPRequestHandler):
self.send_header(key, headers[key]) # why! self.send_header(key, headers[key]) # why!
self.end_headers() self.end_headers()
def do_GET2(self): def __do_GET2(self):
if self.path == "/close": if self.path == "/close":
return self.close() return self.close()
@@ -108,10 +113,14 @@ class ServerLogic(qqq.BaseHTTPRequestHandler):
return return
def do_GET(self): def do_GET(self):
self.youJustHaveToDoTheseStuff()
if self.path == "/close": if self.path == "/close":
return self.close() return self.close()
elif self.path == "/endp": if self.path == "/":
self.header_setup(200, {"Content-type": "application/json"}) self.header_setup()
with open("index.html", "rb") as file:
self.wfile.write(file.read())
return
(connectio, eror) = get_that_connection(connectionSettings) (connectio, eror) = get_that_connection(connectionSettings)
if eror: if eror:
print("coneti eror: ", eror) print("coneti eror: ", eror)
@@ -123,11 +132,28 @@ class ServerLogic(qqq.BaseHTTPRequestHandler):
except Exception as e: except Exception as e:
print(e) print(e)
return # return ealy no else return # return ealy no else
if self.path == "/endp":
self.header_setup(200, {"Content-type": "application/json"})
c = process_tuples(w) c = process_tuples(w)
print(w, c, sep="\n") print(w, c, sep="\n")
self.wfile.write(str(c).encode()) self.wfile.write(str(c).encode())
return return
else: else:
with connectio.cursor(buffered=True) as cur:
try:
res = cur.execute("select neme, kewod from tbale")
wd = cur.fetchall()
except Exception as e:
print(e)
return # return ealy no 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.header_setup(404)
self.wfile.write( self.wfile.write(
b""" b"""
@@ -137,7 +163,7 @@ class ServerLogic(qqq.BaseHTTPRequestHandler):
) )
return return
def do_POST2(self): def __do_POST2(self):
if self.path == "/close": if self.path == "/close":
return self.close() return self.close()
self.header_setup() self.header_setup()
@@ -183,19 +209,29 @@ class ServerLogic(qqq.BaseHTTPRequestHandler):
return return
def do_POST(self): def do_POST(self):
self.youJustHaveToDoTheseStuff()
match self.path: match self.path:
case "/close": case "/close":
return self.close() return self.close()
case "/endp": case "/endp":
self.header_setup() self.header_setup()
content_type = self.headers.get("Content-Type")
content_length = int(self.headers["Content-Length"]) content_length = int(self.headers["Content-Length"])
with self.rfile as r: 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( 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 + post_data_bytes
) )
if content_type == "application/json":
try: try:
data_dict: dict = json.loads(post_data_bytes.decode("utf-8")) data_dict: dict = json.loads(post_data_bytes.decode("utf-8"))
except Exception as e: except Exception as e:
@@ -204,7 +240,8 @@ class ServerLogic(qqq.BaseHTTPRequestHandler):
if eror: if eror:
print("coneti eror: ", eror) print("coneti eror: ", eror)
self.wfile.write( self.wfile.write(
b"the thing cant even start like what f: " + str(eror).encode() b"the thing cant even start like what f: "
+ str(eror).encode()
) )
return return
print((*data_dict.keys(), *data_dict.values())) print((*data_dict.keys(), *data_dict.values()))
@@ -212,7 +249,10 @@ class ServerLogic(qqq.BaseHTTPRequestHandler):
try: try:
res = cur.execute( res = cur.execute(
"insert into tbale (kewod, expi) values (?, ?);", "insert into tbale (kewod, expi) values (?, ?);",
(data_dict["kewod"],data_dict["expi"],), (
data_dict["kewod"],
data_dict["expi"],
),
multi=True, multi=True,
) )
@@ -227,6 +267,9 @@ class ServerLogic(qqq.BaseHTTPRequestHandler):
cur.execute("select * from tbale") cur.execute("select * from tbale")
self.wfile.write(b"\n We have this in the this: ") self.wfile.write(b"\n We have this in the this: ")
self.do_GET() self.do_GET()
else:
self.wfile.write(b"\nits of the type: ")
self.wfile.write(content_type.encode())
case _: case _:
self.header_setup(403) self.header_setup(403)
self.wfile.write( 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