hey guys I been trying to host a local server on port 22222 and when someone open it on the browser I get a msgbox saying yes / no - if you click yes it will accept the connection and show index.html basically, if you click no it will return nothing or something, anyway it works perfectly BUT
I'm trying to trigger a second msgbox after you click on the first one with a delay(after command), when you access the first time and click yes, it serves the page but the Established msg does not show up, if you refresh the page than it retriggers the Established msg and than ask again if you want to accept the connection (Bug Alert lol)
basiclly you need to run this code open 127.0.0.1:22222, click yes, than you will not see the its_ok msgbox, unless you do all this again
import sys
from http.server import HTTPServer, SimpleHTTPRequestHandler, test as Brain_Link
import tkinter
import tkinter.messagebox as mbox
window = tkinter.Tk()
window.wm_withdraw()
window.attributes("-topmost", True)
def Start_Brain_Link(*args):
Brain_Link(*args, port=22222)
def its_ok():
mbox.showinfo('A.I','Brain-Link Established!')
def its_bad():
mbox.showinfo('A.I','Brain-Link Attemp Blocked!')
class CORSRequestHandler(SimpleHTTPRequestHandler):
def end_headers (self):
if mbox.askquestion("Warning!", self.client_address[0]+" Requested Brain-Link!", icon='warning') == 'yes':
self.send_header('Access-Control-Allow-Origin', '*')
SimpleHTTPRequestHandler.end_headers(self)
window.after(1000,its_ok)
else:
window.after(1000,its_bad)
if __name__ == '__main__':
Start_Brain_Link(CORSRequestHandler, HTTPServer)