Knowledgebase

How do I run Python scripts?

To run a Python script from a shell, execute the command:

/usr/bin/python /path/to/script.py

To run a Python script from a web browser first upload a file named .htaccess to your public_html directory with following contents:
 

Options +ExecCGI
AddHandler cgi-script .py

Then sure your script ends with .psp or .py, upload it to your web site, chmod it to 755, and then access it in a web browser. Below is a simple example script that you can use to test Python functionality.

<html> 
<% 
import time 
%> 
Hello world, the time is: <%=time.strftime("%Y-%m-%d, %H:%M:%S")%> 
</html>

 If you need assistance setting up Python scripts on your web site, please open a ticket through our help desk or send an email to support@hostgosupport.com.

  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

What version of Python is supported?

We support Python version 2.2.3 on all of our web servers.

How do run Servlets and JSP scripts on my web site?

The first thing you'll need to do is send a request to tech@hostgosupport.com, requesting for...

How do I connect to a MySQL database from a Java script using JDBC?

Upload the file http://www.hostgosupport.com/downloads/mm.mysql-2.0.11-bin.jar to the directory...

How do I restart the Java Servlet service?

Send a request to support@hostgosupport.com asking for Tomcat service to be restarted. Make sure...

How do I deploy a .war archive?

There are 3 ways to deploy a Java .war archive. 1) .war file to your web site and execute the...