a hell lot
you dont know
This commit is contained in:
1 parent
28bf714147
commit
853dd7871d
3 files changed
+100
-47
No files matched your search
+90
-47
@@ -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,26 +113,47 @@ 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()
|
||||||
|
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"})
|
self.header_setup(200, {"Content-type": "application/json"})
|
||||||
(connectio, eror) = get_that_connection(connectionSettings)
|
c = process_tuples(w)
|
||||||
if eror:
|
print(w, c, sep="\n")
|
||||||
print("coneti eror: ", eror)
|
self.wfile.write(str(c).encode())
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
with connectio.cursor(buffered=True) as cur:
|
with connectio.cursor(buffered=True) as cur:
|
||||||
try:
|
try:
|
||||||
res = cur.execute("select * from tbale")
|
res = cur.execute("select neme, kewod from tbale")
|
||||||
w = cur.fetchall()
|
wd = cur.fetchall()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
return # return ealy no else
|
return # return ealy no else
|
||||||
c = process_tuples(w)
|
# print(wd)
|
||||||
print(w, c, sep="\n")
|
for a, v in wd:
|
||||||
self.wfile.write(str(c).encode())
|
# print(a,v)
|
||||||
return
|
# print(self.path, a)
|
||||||
else:
|
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,50 +209,67 @@ 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
|
||||||
)
|
)
|
||||||
try:
|
if content_type == "application/json":
|
||||||
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:
|
|
||||||
try:
|
try:
|
||||||
res = cur.execute(
|
data_dict: dict = json.loads(post_data_bytes.decode("utf-8"))
|
||||||
"insert into tbale (kewod, expi) values (?, ?);",
|
|
||||||
(data_dict["kewod"],data_dict["expi"],),
|
|
||||||
multi=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
print(res)
|
|
||||||
except Exception as e:
|
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(
|
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:
|
return
|
||||||
print(cur)
|
print((*data_dict.keys(), *data_dict.values()))
|
||||||
cur.execute("select * from tbale")
|
with connectio.cursor(prepared=True) as cur:
|
||||||
self.wfile.write(b"\n We have this in the this: ")
|
try:
|
||||||
self.do_GET()
|
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 _:
|
case _:
|
||||||
self.header_setup(403)
|
self.header_setup(403)
|
||||||
self.wfile.write(
|
self.wfile.write(
|
||||||
|
|||||||
@@ -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>
|
||||||
Reference in new issue
Block a user