Exemple #1
0
        public string getRedirectURL()
        {
            string URL;

            if (WebServerManager.isRedirecting(out URL))
            {
                if (URL[0] == '/')
                {
                    return(URL);
                }
                else
                {
                    return('/' + URL);
                }
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
        public override ReturnType excuteScript(out string HTMLOutput)
        {
            //HTMLOutput = "";

            try
            {
                if (!compiled)
                {
                    compileScript();
                }

                TextWriter   tw = new StringWriter();
                MemoryStream ms = new MemoryStream();

                pythonRuntime.IO.SetOutput(ms, tw);

                var result = compiledScript.Execute(pythonScope);

                string errorCode, errorMessage, redirectURL;

                if (WebServerManager.isError(out errorCode, out errorMessage))
                {
                    HTMLOutput = "";
                    return(ReturnType.Error);
                }

                if (WebServerManager.isRedirecting(out redirectURL))
                {
                    HTMLOutput = "";
                    return(ReturnType.Redirect);
                }

                HTMLOutput = tw.ToString();
                return(ReturnType.HTML);
            }
            catch (Exception ex)
            {
                HTMLOutput = ex.Message;
                return(ReturnType.HTML);
            }
        }