开发者

Run a remote python script from ASP.Net

I have a python script on a linux server that I can SSH into and I want to run the script on the linux server( and pass it parameters开发者_JS百科 entered by the user) and get the output on an ASP.net webpage running on IIS. How would I be able to do that?

Would it be easier if I was running a wamp server?

Edit: The servers are in the same internal intranet.


Probably the best approach is the least coupled one. If you can determine a protocol that you're comfortable with the two (asp/python) talking in, it will go a long way to reducing headaches.

Let's say you pick XML.

Setup the python script to run as a WSGI application with either cherrypy or apache (or whatever). The script formats it's response in XML and passes that to WSGI which returns the XML over HTTP.

On the ASP.NET side of things, whenever you want to "run the script" you simply query the URL with the WebRequest class, then parse the results with LINQ-to-XML (which on a side note is a really cool technology).

Here's where this becomes relevant: Later on if either the ASP.NET implementation or the python implementation changes you don't have to re-code/refactor the other. Later if you realize that the ASP.NET app and some desktop app need to be able to do that, you've standardized on a protocol and implementing it should be easy and well supported.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜