tags:

views:

100

answers:

1

Is there any way to set the directory where you want to start a SimpleHTTPServer or BaseHTTPServer?

Thanks

A: 

If you're using SimpleHTTPServer directly from command line, you can simply use shell features:

pushd /path/you/want/to/serve; python -m SimpleHTTPServer; popd
nailxx
No, I'm using it from inside an application.
Ubersoldat
@Ubersoldat: Then answer's the same: Use the shell to set the current working directory. Or use `os.setcwd()` -- it's the same thing.
S.Lott
@S.Lott os.setcwd doesn't exist, but os.chdir(path) does the job. Thanks to both.
Ubersoldat
@Ubersoldat: Apologies -- I did that from memory. Wish I could edit the comment.
S.Lott