Configuraion to run pyhton script on ubuntu 12.04
want to run a python script which contains simple form of html on firefox browser , but dont know what should be the configuration on ubuntu 12.04 to run this script i.e cgi configuration My code is ubder in /var/www/cgi-bin/forms__.py #!/usr/bin/env python import webapp2 form =""" """ class MainPage(webapp2.RequestHandler): def get(self): #self.response.headers['Content-Type'] = 'text/plain' self.response.out.write(form) app = webapp2.WSGIApplication([('/', MainPage)], debug=True) -- http://mail.python.org/mailman/listinfo/python-list
Re: Configuraion to run pyhton script on ubuntu 12.04
Sir i already tried this "Alias" concept I did the following steps === Step 1: added "ScriptAlias /cgi-bin/ /var/www/cgi-bin/" in /etc/apache2/sites-available/default step 2:- added :- def main(): app.run() if __name__ == '__main__': main() in /var/www/cgi-bin/hello_world.py Now my Configuration of /etc/apache2/sites-available/default in under ServerAdmin webmaster@localhost DocumentRoot /var/www Options FollowSymLinks AllowOverride None AddHandler mod_python .py PythonHandler mod_python.publisher | .py AddHandler mod_python .psp .psp_ PythonHandler mod_python.psp | .psp .psp ScriptAlias /cgi-bin/ /var/www/cgi-bin/ Options Indexes FollowSymLinks MultiViews ExecCGI AllowOverride None Order allow,deny allow from all AddHandler cgi-script cgi pl #ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch AddHandler cgi-script cgi pl Order allow,deny Allow from all ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined Alias /doc/ "/usr/share/doc/" Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 === my code is under /var/www/cgi-bin/hello_world.py import webapp2 class MainPage(webapp2.RequestHandler): def get(self): self.response.headers['Content-Type'] = 'text/plain' self.response.out.write('Hello, webapp World!') app = webapp2.WSGIApplication([('/', MainPage)], debug=True) def main(): app.run() if __name__ == '__main__': main() = extra thing i did in /etc/apache2/mods-available/mod_python.conf where i created the file "mod_python.conf" AddHandler mod_python .py .psp PythonHandler mod_python.publisher | .py PythonHandler mod_python.psp | .psp when i run localhost/cgi-bin/hello_world.py error i get Not Found The requested URL /cgi-bin/hello_world.py was not found on this server. Apache/2.2.22 (Ubuntu) Server at localhost Port 80 # -- http://mail.python.org/mailman/listinfo/python-list
Re: Configuraion to run pyhton script on ubuntu 12.04
Problem solved regarding cgi configuration on ubuntu 12.04 lts Concept:-) file used:-) /etc/apache2/httpd.conf /etc/apache2/sites-available/default steps done 1:-) in /etc/apache2/httpd.conf added line #for link localhost/python2/hello.py ScriptAlias /python2/ /var/www/python2/ AllowOverride None Options +Indexes FollowSymLinks +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all ###fro runing of python script AddHandler cgi-script cgi pl mod_python .py PythonHandler mod_python.publisher | .py AddHandler mod_python .psp .psp_ PythonHandler mod_python.psp | .psp .psp PythonDebug On # step done 2:-) added line ###fro runing of python script AddHandler cgi-script cgi pl mod_python .py PythonHandler mod_python.publisher | .py AddHandler mod_python .psp .psp_ PythonHandler mod_python.psp | .psp .psp PythonDebug On between - --- HERE I ADDED Line - - - --- HERE I ADDED Line - - Step Done 3:-) added line in /etc/apache2/mods-available/mod_python.conf ##mod_python.conf i created AddHandler mod_python .py .psp PythonHandler mod_python.publisher | .py PythonHandler mod_python.psp | .psp -- http://mail.python.org/mailman/listinfo/python-list
AssertionError: Headers already set! Status: 500 Internal Server Error Content-Type: text/plain Content-Length: 59
learning web concpt in python wrote code in /usr/lib/cgi-bin/hello_world.py ### #!/usr/bin/env python import webapp2 form =""" http://www/google.com/search";> """ class MainPage(webapp2.RequestHandler): def get(self): self.response.out.write(form) class TestHandler(webapp2.RequestHandler): def get(self): q=self.request.get("q") self.response.out.write(q) apps = webapp2.WSGIApplication([('/', MainPage),('/testform',TestHandler)],debug=True) def main(): apps.run() if __name__ == '__main__': main() ### when running this code on ubuntu 12.04 using command python hello_world.py error obtained AssertionError: Headers already set! Status: 500 Internal Server Error Content-Type: text/plain Content-Length: 59 ## want help please urgent -- http://mail.python.org/mailman/listinfo/python-list
ImportError: No module named appengine.ext
hey learning python problem facing is under when typing on interpreter >>> from google.appengine.ext import db Traceback (most recent call last): File "", line 1, in ImportError: No module named appengine.ext what to do please help . -- http://mail.python.org/mailman/listinfo/python-list
Re: ImportError: No module named appengine.ext
you mean to say SDK for python ?/ -- http://mail.python.org/mailman/listinfo/python-list
How to install googleapp engine on ubuntu 12.04 already downloads google_appengine_1.8.2.zip
How to install googleapp engine on ubuntu 12.04 already did: downloaded google_appengine_1.8.2.zip unziped it now?/ please help -- http://mail.python.org/mailman/listinfo/python-list
os.system() not responding on django... any reason?
import sys,os sys.stderr = open('/dev/null') import paramiko sys.stderr = sys.__stderr__ os.system("echo \'s3\' >> myfile.txt ") #debug first in ssh2 def ssh2_connect(host, user, pswd, port=22): try: ssh = paramiko.SSHClient() ssh.load_system_host_keys() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(host, port, user, pswd) return ssh except Exception, e: return str(e) + "Error. Failed to connect. Wrong IP/Username/Password" def ssh2_exec(ssh, cmd, sudo=False): result = [] try: channel = ssh.get_transport().open_session() if sudo: channel.get_pty() except: return result stdin = channel.makefile('wb') stdout = channel.makefile('rb') channel.exec_command(cmd) exit_status = channel.recv_exit_status() if exit_status == 0: for line in stdout: result.append(line) channel.close() return result def ssh2_close(ssh): ssh.close() return def ssh2_copyToFile(ssh, local_file, remote_file): sftp = paramiko.SFTPClient.from_transport(ssh.get_transport()) sftp.put(local_file, remote_file) return -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system() not responding on django... any reason?
it is running in view.. -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system() not responding on django... any reason?
in django inviroment.. -- http://mail.python.org/mailman/listinfo/python-list