How would I use to execute ASP/PHP server files?
Or can not do that and can someone provide me a python script that can execute ASP/PHP server files?
Should I try posting this in the PHP forum, Web Design, html, and css fourm, or the Web development forum if I don't get an awnser here?

Recommended Answers

All 2 Replies

The correct solution would be to serve as fastcgi together with PHP and ASP, this should be managed by a server as Apache or Nginx. But if you want to try the built in server you could do something like this:

#!/usr/bin/env python

import web
from subprocess import check_output

urls = (
    '/', 'index',
    '/reverse', 'reverse'

class index:
    def GET(self):
        return "Hello, world!"

class reverse:
    def GET(self):
        x = web.input(arg1='')
        r = check_output(["./reverse.php", "%s" % x.arg1])
        return "Reverse of " + x.arg1 + " is " + r

if __name__ == "__main__":
    app = web.application(urls, globals())

Then as PHP script:

#!/usr/bin/env php

    echo strrev($argv[1]);

Make the php script executable:

chmod 755 reverse.php

Otherwise change this line:

r = check_output(["./reverse.php", "%s" % x.arg1])


r = check_output(["/usr/bin/env php reverse.php", "%s" % x.arg1])

And then try the url:


It should output olleh. Note mine is just a test, this is not good for production usage.


Sorry for the update, I did a little error in my previous post, regarding the alternative to call the PHP executable. The correct version is this:

r = check_output(["/usr/bin/env", "php", "./reverse.php", "%s" % x.arg1])

Otherwise it will output an exception, I haven't noticed it before because I forgot to restart the server.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.