Python Forum
The CGI can't run on EXE which packaged
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The CGI can't run on EXE which packaged
#1
Hello guys:
I wrote a litter program. It can running on linux and windows. But when I packaged it on Windows and run it, the html file could run normally,but when visit the CGI files, the error was happend . The commandline show:

Error:
192.168.0.21 - - [09/May/2018 14:54:14] "GET /cgi-bin/main.py HTTP/1.1" 200 - 192.168.0.21 - - [09/May/2018 14:54:14] command: D:\damai\server.exe -u D:\damai \cgi-bin\main.py "" 192.168.0.21 - - [09/May/2018 14:54:15] b'[3976] Failed to execute script server \r\nTraceback (most recent call last):\r\n File "server.py", line 73, in <modul e>\r\n welcome()\r\n File "server.py", line 41, in welcome\r\n mod_choice =str(input("\xc7\xeb\xd1\xa1\xd4\xf1\xa3\xba"))\r\nEOFError: EOF when reading a line\r\n' 192.168.0.21 - - [09/May/2018 14:54:15] CGI script exit status 0xffffffff 192.168.0.21 - - [09/May/2018 14:54:15] code 404, message File not found 192.168.0.21 - - [09/May/2018 14:54:15] "GET /favicon.ico HTTP/1.1" 404 -
This is the code:
def welcome():
    print('TIP1!')
    print('HTTPS://AILS.TOP')
    print('=='*16)
    print('TIP2:')
    print('=='*16)
    mod_choice=str(input("TIP3:"))
    if mod_choice=="1":
        print("TIP4")
        fullpath=str(input(""))
        if os.path.isfile(fullpath):
            add_path(fullpath)
            qr_url="http://"+ip+":8080/cgi-bin/download.py?filename="+path
            creatQR(qr_url)
        else:
            print(colored("WARNING:TIP5!","yellow"))
            print()
            welcome()
    elif mod_choice=="2":
        print("TIP6")
        fullpath=str(input(""))
        add_path(fullpath)
        qr_url="http://"+ip+":8080/cgi-bin/main.py"
        creatQR(qr_url)
    elif mod_choice=='0':
        exit()
    else:
        print(colored("TIP7!","yellow"))
        print()
        welcome()
        
if __name__ == '__main__':
    try:
        handler = CGIHTTPRequestHandler
        handler.cgi_directories = ['/cgi-bin', '/htbin']
        port = 8080
        server = HTTPServer(('', port), handler)
        ip=get_host_ip()
        welcome()
        webbrowser.open("index.html", new=0, autoraise=True)
        print(colored("TIP8","yellow"))
        print()
        server.serve_forever()
Thanks!
Reply
#2
Use python tags, not quotes for code
Reply
#3
(May-09-2018, 12:40 PM)Larz60+ Wrote: Use python tags, not quotes for code
Sorry,I am a beginner. Thanks for your help!
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020