0

So i am trying to make a Growtopia Server Emulator but i actually got this confusing error. I couldn't find anything about...

Here's my code

import cgi #not used yet
import http.server
import logging #not used yet
import socketserver

class ServerHandler(http.server.BaseHTTPRequestHandler):
         def do_POST(self):
             self.send_response(200)
             self.end_headers()
             self.wfile.write("server|127.0.0.1\nport|17091\ntype|1\n#maint|Mainetrance message (Not used for now) -- Growtopia Noobs\n\nbeta_server|127.0.0.1\nbeta_port|17091\n\nbeta_type|1\nmeta|localhost\nRTENDMARKERBS1001")
         def do_GET(self):
             self.send_response(200)
             self.end_headers()
             self.wfile.write("server|127.0.0.1\nport|17091\ntype|1\n#maint|Mainetrance message (Not used for now) -- Growtopia Noobs\n\nbeta_server|127.0.0.1\nbeta_port|17091\n\nbeta_type|1\nmeta|localhost\nRTENDMARKERBS1001")
         def log_message(self, format, *args):
             return
PORT = 80
HOST = ""

Handler = http.server.SimpleHTTPRequestHandler,ServerHandler

OUT_HOST = HOST
httpd = socketserver.TCPServer((HOST, PORT), Handler)
print("Server Port : ", PORT)
if OUT_HOST == "" or " " or "\n":
 print("Server Hostname : ", "localhost")
else:
 print("Server Hostname : ", HOST)

httpd.serve_forever()


  • 3
    What's the exact with trace? Also note that `if OUT_HOST == "" or " " or "\n"` doesn't work as you expect. [This](https://stackoverflow.com/questions/15112125/how-to-test-multiple-variables-against-a-value) question explains why – Carcigenicate Sep 09 '20 at 23:34
  • 1
    `Handler = http.server.SimpleHTTPRequestHandler,ServerHandler` looks suspicious though. That comma at the end makes `Handler` a tuple, not a function. What are you meaning to do there? – Carcigenicate Sep 09 '20 at 23:35
  • 1
    @pythomatic That seems unlikely. It would need to be treated as a function to lead to that error, and I can't see why an `address` field would need to be called. Also, it's quite common to have a `(HOST, PORT)` as an "address" in Python libraries. – Carcigenicate Sep 09 '20 at 23:37
  • The first argument to `TCPServer` is eventually passed to `socket.bind` internally, which means that a tuple is appropriate as the first argument. – Carcigenicate Sep 09 '20 at 23:40
  • The second argument to socketserver.TCPServer is supposed to be a class. You are passing a tuple. I believe you can only pass a single Handler to this function. I'm not quite sure what you're trying to achieve by passing a tuple of two handlers. – Frank Yellin Sep 09 '20 at 23:43
  • https://docs.python.org/2/library/simplehttpserver.html – isGrounded Sep 10 '20 at 03:12

1 Answers1

0

I fixed that issue by Adding Handler = http.server.SimpleHTTPRequestHandler into ServerHandler Class.