/// <summary> /// Start application and initialize all needed systems /// </summary> protected void Application_Start() { // Create scripting language = new IronPythonLanguage(); host = new DlrHost<IronPythonLanguage>(language); host.AddImportResolver(new NoImporter()); // Search paths Host.AddSearchPath(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath); // Load app.py and execute var source = Host.ScriptEngine.CreateScriptSourceFromString ( System.IO.File.ReadAllText(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "app.py") ); source.Execute(Host.DefaultScope.ScriptScope); app = (AspNetMvcAPI.Application)Host.DefaultScope.CreateClassInstance("App").Instance; // Call start app.start(); }
static void Main(string[] args) { if (args.Length > 0) { // Create host var language = new IronPythonLanguage(); language.Argv = args.ToList(); var host = new DlrHost<IronPythonLanguage>(language); host.AddSearchPath(@"C:\Program Files (x86)\IronPython 2.7\Lib\"); host.AddSearchPath(System.IO.Path.GetDirectoryName(args[0])); try { host.DefaultScope.ExecuteScript(args.First()); } catch (Exception ex) { Environment.Exit(1); } } }