Пример #1
0
        public Webhost()
        {
            Get("/", async x =>
            {
                return(View["public/index.html"]);
            });

            // Decompiler API (only 5.1)
            Post("/api/decompile", async x =>
            {
                // TODO: add protection to prevent spam?

                // check attached files
                var file = this.Request.Files.FirstOrDefault();
                if (file != null)
                {
                    byte[] LuaC = new byte[file.Value.Length];
                    file.Value.Read(LuaC, 0, (int)file.Value.Length);
                    return(Response.AsJson <APIResponse <ResponseDecompiler> >(APIHelper.Decompile(LuaC)));
                }

                // check body as bytecode
                string content = Request.Body.AsString();
                if (content.Substring(1, 3) == "Lua")
                {
                    return(Response.AsJson <APIResponse <ResponseDecompiler> >(APIHelper.Decompile(Encoding.UTF8.GetBytes(content))));
                }

                return(Response.AsJson <APIResponse <ResponseDecompiler> >(APIHelper.Decompile(null))); // its for error handling
            });

            Post("/api/elipmoced", async x =>
            {
                // NOTE: this one is a joke xD
                return(Response.AsRedirect("https://www.youtube.com/watch?v=dQw4w9WgXcQ"));
            });

            // Lua Beautifier API
            Post("/api/beautifie/", async x =>
            {
                return(Response.AsJson <APIResponse <ResponseBeautifier> >(APIHelper.Beautifie()));
            });

            // Highlight API
            Post("/api/highlight/", async x =>
            {
                return(Response.AsJson <APIResponse <ResponseHighlighter> >(APIHelper.Highlight()));
            });
        }