Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to get python's SimpleHTTPServer to start on boot using /etc/init/pyweb.conf and to specify the path which the script will be executed in and server files from, however I don't seem to be able to get it to work.

Here's what I have ended up with, but it's not firing off:

# Start SimpleHTTPServer
#
description "SimpleHTTPServer"
start on startup
task
exec python -m SimpleHTTPServer 
--path=/var/pyweb/
share|improve this question

migrated from stackoverflow.com Sep 21 '11 at 13:44

This question came from our site for professional and enthusiast programmers.

Change to a directory containing web files, for example:

cd /var/www/test

Run this command:

python -m SimpleHTTPServer

If the default port (8000) isn't available, you can try a different one by adding it to the command:

python -m SimpleHTTPServer 1234

Once this is working, you can run the command below to make the server persistent:

nohup python -m SimpleHTTPServer 1234 &

share|improve this answer
    
Your solution duplicates an earlier one (please do read all answers before posting a new one), and as the OP is using upstart there's no use for nohup (although for anyone doing the same without upstart it would be useful). – zagrimsan Nov 25 '15 at 10:56

Add chdir /var/pyweb before your exec-line.

Described here: http://upstart.ubuntu.com/wiki/Stanzas#chdir

Edit: To be clear, SimpleHTTPServer doesn't take any --path or other options like that. You can give it a port number, that's about it.

Also, you don't want to use it as something permanent (i.e. on boot, used a lot); use a real httpd for that.

Thirdly; this is more of ServerFault question.

share|improve this answer
    
Thanks very much for suggestions adding the chdir solved it. This is to be used for a touchscreen web config, the web server will probably serve one page during initial setup and potentially never serve another page unless the config is changed which is unlikely. many thanks again. – crankshaft Sep 21 '11 at 13:18

Maybe

cd

into that folder and run

python -m SimpleHTTPServer

from there?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.