Created
September 25, 2010 19:33
-
-
Save muhuk/597184 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import os | |
import cherrypy | |
def get_options(): | |
host, port = '0.0.0.0', 8010 | |
if len(sys.argv) > 2: | |
bits = sys.argv[2].split(':') | |
if len(bits) > 1: | |
host, port = bits[0], int(bits[1]) | |
else: | |
host = bits[0] | |
if len(sys.argv) > 1: | |
path = sys.argv[1] | |
else: | |
path = os.getcwd() | |
return host, port, path | |
def configure(): | |
host, port, path = get_options() | |
cherrypy.server.max_request_body_size = 0 | |
cherrypy.server.socket_timeout = 60 | |
cherrypy.config.update({ | |
'server.socket_host': host, | |
'server.socket_port': port, | |
'server.thread_pool': 2, | |
}) | |
cherrypy.tree.mount(None, '/',{'/': { | |
'tools.staticdir.on': True, | |
'tools.staticdir.dir': path, | |
'tools.staticdir.index': 'index.html', | |
}}) | |
print('Server root is: "%s"' % path) | |
def main(): | |
configure() | |
try: | |
print("Starting server...") | |
cherrypy.engine.start() | |
cherrypy.engine.block() #this allows for control-c shutdown | |
except KeyboardInterrupt: | |
print("Keyboard interrupt, shutting down server") | |
cherrypy.engine.stop() | |
print("Server shutdown successful") | |
if __name__ == '__main__': | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
python -m smtpd -n -c DebuggingServer localhost:1025 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment