Why is my python script not running in shared hosting cpanel GoDaddy - python

I have shared hosting for my website at Godaddy with shared hosting in cpanel. I made a python script that print hello and I even tried with the GUI too but it is not printing. It is only showing the code. I called GoDaddy and they said to do print("Hello World") but even though I did it is still not working. Right now my code is print("Hello World"). Printing hello world like that normally works but it is not working. I need to use python 2.6.6 because that's what GoDaddy gives as the version number for python. Please can somebody help?
You can check out my python script in my website at My python script in my website.

You use Apache Web server, and it doesn't process you python script. It consider it as static file and return it's content.
There are a few ways to make it work
mod_python for your Apache server
Use CGI
Make apach proxy to python web server by your choice (e.g. gunicorn)

I found out that python is installed on it but it doesn't let you run python scripts in godaddy economy hosting cpanel. Thanks!

Related

ASP.NET webpage on IIS Server does not call Python/run scripts at all

I've developed an ASP.NET website on IIS (virtual Windows Server using Amazon Lightsail) which works as expected for the most part. But one issue with it is with running specialized Python scripts.
In my website, there is a feature where a user (of a certain account level) can upload an image, which is then passed through Python (through Process.Start). After Python does its thing, it sends text output back to the webpage. This works perfectly under the context of IIS Express in my local computer, but on the server, it seems to not run Python at all.
It is noted that I did not receive any warnings or errors. Seems to entirely skip the Process.Start segment.
I suspect that it is due to either of these:
Security access
The application pool
The Process.Start function
Things I tried:
Changing the security settings of the folder with the Python app and the scripts, as well as the Python executable
Changing the application pool of the website to LocalSystem
Disabled dynamic compression
Added a script map for the Python app
Reinstalled Python from Users/Administrator/Local/Appdata... to C:/Python (also changed the required paths in the website code behind) I also made sure that I installed the right Python libraries for the code to work.
Apart from the file paths in the code behind, nothing is changed in the actual ASP.NET website and DLL. Ideally I should not need to change anything else with regards to the website.
The website still does not call Python. I've been scratching my head for the past two days on this single issue.
Also, the folder where the Python scripts and related files are located are within wwwroot.
Any suggestions are much appreciated.
TL;DR: ASP.NET website that calls Python to run an already-coded script as part of its function works great under IIS Express. Python does not run when called under IIS Server.

Setup for running simple python scripts on (Nginx) web server?

I would like to run a couple of very simple Python 3 scripts on the web. As an example, say, the script just reads certain parameters from the URL, sends an email and prints out a simple HTML page saying "success".
I have a virtual private server with Nginx, so I am free to setup the best framework.
My question is: what is the state-of-the-art setup to do this?
More particularly: what do I need to install on my server for Nginx and what do I use in my Python scripts for e.g. reading the URL content? My idea is, that once the server setup is done, I can just put any new script_xy.py file into some directory and it can be accessed using the URL of the script, without a full blown deployment for each script.
Flask If I were to use Flask (or Django), each new script would need its own, continuously running process and its own Nginx setup. That seems like a total overkill to me. Another alternative is web2py, is it the same here or would that be an idea?
CGI 20 years ago I used to program such simple things as Perl scripts using CGI. I read this can be done in principle with Python, but CGI is slow. Then there is Fast CGI. However, my impression was that this is still a bit outdated?
WSGI WSGI seems to be the state-of-the-art alternative to CGI for Python. What python modules would I need to import in my script and what would be the setup for Nginx?
Something else? As you see, I might just need a few hints on what to search for. I am not even sure if I need to search for "Python web framework" or "Python server" etc.
Any help is greatly appreciated.
Thanks a lot for your ideas!
juxeku

Deploy Python webApp on AWS (without using Elastic Beanstalk)

I'm hosting a website on AWS. Its a web interface with a SQL database. The website will be used to:
1. View results of query from Database
2. Insert data into database
3. View the data and update it where needed.
The codes and connections works file when I run the application on localhost (Apache on my C drive). But we want to host it on AWS so that people around me can use it.
So, In AWS I uploaded the code on EC2 and installed apache on it, all the html links are working but the python file is simply displaying the code.
I'm guessing it has something to do with the shebang. Currently my code has the following shebang:
#!C:\Python27\python.exe
Can someone guide me if its the shebang or if there is something else i need to do.
I have installed boto, but not sure what to do next. The AWS website and most of the forums talk about using Elastic Beanstalk. I want to host a fully functioning Python webApp on AWS without using Elastic Beanstalk.
When apache displays code, that is a clear sign that Apache is not configured properly to execute python. You should look to see if mod_python is installed and configured correctly.
Also, #! is generally used with Linux not windows. If apache/mod_python is installed and configured correctly I can't imagine what code you'd have that would need #! since the .py extension would be enough.
IF your EC2 instance is indeed running Linux, and your code does indeed need #! try:
#!/bin/python
OR
#!/usr/local/bin/python
(Depends on where the python binary is, and those are the most common locations.)
If your EC2 instance is running Windows then "Unless you are using cygwin, windows has no shebang support"
Hi have you logged into your EC2 instance through the endpoint and then run your script, from the command line. I have some experience with EC2 running apache2 only my application was written in Java, having previously used python scripts I was able to run them by logging into my EC2 instance, you can do this from AWS management console. hope this helps you somewhat.

Simple Python server setup

I am trying to learn python (coming from PHP), and want to set up the simplest web server so I can start coding.
I found the integrated HTTP server, so I figured it should be the easiest way.
root#ubuntu:/var/py# python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...
The webserver is working, accessing http://test.dev:8000/test.py (thanks /etc/hosts) works - but shows me the contents of the file ( print('Hello world!'); ), without interpreting it.
How to properly set up the server / interpretor ?
Python is for writing programs in general, not only web-sites.
SimpleHTTPServer is really just a trivial HTTP server, it serves files. It doesn't try to interpret code.
If you want to do web-development with Python, you should be using a web framework. web.py is a good choice, you can check its tutorial. Another option is Django, which also has a brilliant tutorial.
Both of them have simple development servers built in, so you'll be able to start experimenting easily.
If you are just starting out with python I would recommend you start with scripts that can be run from the console using python interpreter. (eg: python run1.py)
Once you have mastered the basics, you can move onto web programming. (I am guessing that you want to try web programming since you mention a web server.) In this case, you have multiple options (all of which work with Apache):
Django framework : Really good framework, has a built-in webserver and has fantastic documentation (http://www.djangobook.com/en/2.0/index.html).
You need to know python basics first
WSGI: https://code.google.com/p/modwsgi/ : Apache module for running python code

Execute python script in localhost

I have downloaded and installed python on my PC. I am learning python at this moment so I am a beginner.
Is there anyway I could execute python scripts in localhost (Apache) and view them in a web browser as we do with PHP? I am executing the python scripts from CLI at this moment.
Although there are multiple solutions, I would take a look at mod_python. Unfortunately, in my experience it is not the easiest thing in the world to set up and requires making changes to httpd.conf, but this tutorial is helpful (and gives some examples).
Google App Engine SDK for Python includes a local web server application that simulates the App Engine environment. It allows for instant server script changes by just saving the file and refreshing the browser.
The development tutorial is here
Once you have your web site working locally, it is easy to deploy it live on Google's App Engine servers.

Categories