Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch for having generic IP #76

Open
ghost opened this issue Jul 1, 2015 · 0 comments
Open

Patch for having generic IP #76

ghost opened this issue Jul 1, 2015 · 0 comments

Comments

@ghost
Copy link

ghost commented Jul 1, 2015

Hi,

I submit a patch for changing the IP. Bye default it's 0.0.0.0:

#!/usr/bin/env python2

import CGIHTTPServer
import BaseHTTPServer
from optparse import OptionParser

class Handler(CGIHTTPServer.CGIHTTPRequestHandler):
    cgi_directories = ["/cgi-bin"]

IP = "0.0.0.0"
PORT = 8000

def main():
    parser = OptionParser()
    opts, args = parser.parse_args()
    if args:
        httpd = BaseHTTPServer.HTTPServer((args[0], int(args[1])), Handler)
        print "Collectd-web server running at http://%s:%s/" % (args[0], args[1])
    else:
        httpd = BaseHTTPServer.HTTPServer((IP, PORT), Handler)
        print "Collectd-web server running at http://%s:%s/" % (IP, PORT)
    httpd.serve_forever()

if __name__ == "__main__":
    main()

Please, consider to put options like --ip or --port to override the default options. Useful for newbees for not having to change source code.

Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants