def exec_module(module, globals=None, locals=None):
    frame = sys._getframe(1)
exec_globals = nvl(globals, {})
copy_globals = exec_globals.copy()
exec_globals.update(frame.f_globals)
exec_globals.update(copy_globals)
exec_locals = nvl(locals, {})
copy_locals = exec_locals.copy()
exec_locals.update(frame.f_locals)
exec_locals.update(copy_locals)
exec(compile(module.__loader__.get_source(module.__name__), module.__file__,
    'exec'), exec_globals, exec_locals)
Start SimpleHTTPServer in python