Display output from python in aspx page
<p>Question from a .net newbie</p>

<p>Hello,</p>

<p>I am trying to display output from my python code in aspx page.</p>

<p>Below is .net c# code that executes by the click of Button1.</p>

<pre><code>protected void Button1_Click1(object sender, EventArgs e)
{
    ScriptEngine eng = Python.CreateEngine();
    dynamic scope = eng.CreateScope();
    eng.ExecuteFile(@"C:\path\hello.py", scope);
    Label1.Text = //display output in Label1
}
</code></pre>

<p>Below is the sample python script.</p>

<pre><code>print "hello"
</code></pre>

<p>Could you please tell me how to display "hello" in Label1.Text?</p>

<p>Also any kind of information regarding passing data between python and asp.net is appreciated.</p>

<p>Thanks,</p>

<p>You can put all your result in variable a</p>

<p>Example:</p>

<p>Python</p>

<pre><code>a = ""
a += "hello world\n"
a += "==========="
</code></pre>

<p>In C#</p>

<pre><code>ScriptEngine engine = Python.CreateEngine();
ScriptScope scope = engine.CreateScope();
engine.ExecuteFile(@"C:\path\hello.py", scope);
var result = scope.GetVariable("a");
Console.WriteLine(result);
Console.ReadLine();
</code></pre>

c# python asp.net visual-studio ironpython