Writing an HTTP server script loaded by XChat

Discussion about Perl, TCL or Python scripts and C/C++ plugins (using and writing them).

Writing an HTTP serv

Postby ProgVal » 07 Aug 2010 12:40

Hello,

I have a Python script which handle HTTP requests on port 8067. It works when I run it from the command line, but if I load it from XChat, it doesn't answer the requests
Wireshark shows me FireFox sends headers on this port, but the script doesn't answer.

Here is a port of the code :
Code: Select all
class WebHandler(BaseHTTPServer.BaseHTTPRequestHandler):
    do_GET():
        print "foo" # Doesn't print anything when the script is loaded by XChat

import threading, BaseHTTPServer
httpd = BaseHTTPServer.HTTPServer(('', 8067), XChatWebHandler)
threading.Thread(target=httpd.serve_forever, name="XChat Web Frontend server")


Do you know the cause of the bug ?

Thank you in advance,
ProgVal
User avatar
ProgVal
 
Posts: 14
Joined: 15 Feb 2010 09:37

Postby dsuchka » 07 Aug 2010 15:03

Code: Select all
import xchat
...
xchat.prnt("%s %s" % ("foo", "bar"))
dsuchka
 
Posts: 1
Joined: 07 Aug 2010 15:01

Postby ProgVal » 07 Aug 2010 15:14

xchat.prnt and print both do the same thing, don't them ?
User avatar
ProgVal
 
Posts: 14
Joined: 15 Feb 2010 09:37

Postby 2Points » 09 Aug 2010 10:32

They do.

Other than that, did you just omit Thread.start(), or is it missing? You'll need it for doing anything useful with that thread.

You could also check Wireshark if you receive TCP RST on that port or not. If not, it would probably indicate that the port is open and listening. In that case, at least something should happen.
User avatar
2Points
 
Posts: 173
Joined: 21 Dec 2006 18:49

Postby ProgVal » 09 Aug 2010 10:34

I forgot it. Thanks.
User avatar
ProgVal
 
Posts: 14
Joined: 15 Feb 2010 09:37


Return to Scripts and Plugins

Who is online

Users browsing this forum: No registered users and 1 guest

cron