I have a custom business logic written in python – there are various reasons I can’t write it directly in C#/.Net (time constraints etc.).
I tried integrating the python program into .Net using IronPython but cannot (lxml being one of the reasons).
I’m turning to the simpler solution of exposing this python logic as a
web service which .Net can call.
–
First I thought I’d have to host my python code on a separate domain..
But I realized, I can install python on the same server & run this python service !!
The functionality is simple –
.Net passes a URL & the python program returns data as a long string.
1.) What would be the simplest way to do this ?
2.) Do I need to use a framework like web2py/werkzeug or is there something built in I can use ?!
I think I would give Tornado a try. I have been using it in the past, and it was extremely easy to learn.
Anyway, I think I would suggest you to prepare a small webservice running locally (using Tornado). This webservice could be then easily accessed by any code running on the same machine, and if there is a need – from another machine as well.
Oh, and Tornado is much lighter than Django…
(The sample code below is a Hello-World sample from Tornado website – I’ve just copied it here to show how easy it is to use Tornado):
One of the great advantages of Tornado is that it is simple to do simple task but just in case you need something more sophisticated – it is easy to use them.
Oh, and another thing to bear in mind – I don’t know what your code is actually doing but I think it could be a good idea to consider designing your webservice’ API with REST in mind.