Using XAMPP server to run python files is returning only folders containing the program instead of running the program
Got my answer here: Configure Flask dev server to be visible across the network from @Ibz. Shaikh. They go through command Prompt to set this up. Later on, I was able to figure out that in my run.py file I can set the host name to the IP address that I want.
if __name__=='main__':
app.run(debug=True)
change to
app.run(host=<ip address of your server>)
And it will run on {ip address}:5000 (similar to @Jeevan Chaitanya's answer in the aforementioned link).
If you decide to continue using port 8080 where XAMPP is, make sure that your files are stored accordingly. I had to have my run.py file directly in htdocs (path: C:/xampp/htdocs/run.py)... nesting it further caused errors.
From my original question: No, you do not need to add routes to python at the top of each file. Just ensure that your server (i am working on development and using a laptop to practice) runs python.
Running Python Code on Xampp on windows platform
The official releases of mod_wsgi don't support Python 3.2 so you cant use it. To use Python 3.2 you would need to compile mod_wsgi from source code in subversion repository which I would suggest is probably going to be a bit beyond what you are able to do based on problems you are having above. So, use Python 2.6/2.7. Also see:
http://code.google.com/p/modwsgi/wiki/InstallationOnWindows
http://code.google.com/p/modwsgi/wiki/DownloadTheSoftware?tm=2#Windows_Binary_Downloads
As Daniel suggested I would suggest you use Flask. You could also use web2py which is another framework which is easy for newbies. I would also suggest that if you are only starting to learn this stuff that you not use Apache/mod_wsgi and instead just use the inbuilt development server provided by the Python web framework you use. That will save you a lot of headaches initially if you know nothing about Apache.
XAMPP-python script execution
I think the problem is that you have safe mode enabled which prevents execution outside of safe mode directory. See http://php.net/manual/en/function.exec.php description.
You can also try using system() function instead.
I also think that it is not a great idea to call python script from php. :)
EDIT:
If you are on development environment, I would suggest you try to following:
1) copy script.py to the directory where your .php file is.
2) change .php exec line to system('python script.py');
3) if that works, try to call .py in cgi-bin directory. if cgi-bin is one level up from your htdocs directory, you can try system('python ..\cgi-bin\script.py');
I can't try it on my machine, since I run Mac.
4) I looked at safe mode description, it seems it was removed in PHP 5.4.0. So if your version of PHP is higher than that, it should not apply to you.
5) I would suggest also trying forward slashes in path: system('python ../cgi-bin/script.py');
Good luck. Let me know if it helps.
Related Topics
How to Improve My Paw Detection
Python: How to Ignore an Exception and Proceed
Python Create Unix Timestamp Five Minutes in the Future
Ambiguity in Pandas Dataframe/Numpy Array "Axis" Definition
Extracting Specific Columns in Numpy Array
Asyncio.Gather VS Asyncio.Wait
Replace Negative Values in an Numpy Array
Get Column Index from Column Name in Python Pandas
Is There a Difference Between Continue and Pass in a for Loop in Python
How to Find Element by Part of Its Id Name in Selenium with Python
Python Replace String Pattern with Output of Function
Remove All Line Breaks from a Long String of Text
What Does "Error: Option --Single-Version-Externally-Managed Not Recognized" Indicate
Why Isn't the Regular Expression's "Non-Capturing" Group Working
Adding Borders to an Image Using Python
How to Use Boto to Stream a File Out of Amazon S3 to Rackspace Cloudfiles