Example #1
0
        private static string getResp(HttpContext context)
        {
            //(byte[] ret, Error err) = Shared.File.Read(AppPath.GetAppPath() + "/data/ui/index.html");

            Response resp = new Response();

            resp.Version = 1.0;

            SQLite db = new SQLite();


            string par1 = context.Request.Query["par1"];
            string par2 = context.Request.Query["par2"];

            if (par1 == "1")
            {
                db.CreateTable("", AppPath.GetAppPath() + "/data/db.sqlite3");
            }
            else if (par1 == "2")
            {
                db.WriteTable(par2, AppPath.GetAppPath() + "/data/db.sqlite3");
            }
            else if (par1 == "3")
            {
                resp.DB = db.ReadTable("", AppPath.GetAppPath() + "/data/db.sqlite3");
            }

            byte[] b = JsonSerializer.SerializeToUtf8Bytes(resp);
            return(Encoding.UTF8.GetString(b, 0, b.Length));
        }
Example #2
0
        public static void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseStaticFiles(new StaticFileOptions
            {
                FileProvider = new PhysicalFileProvider(AppPath.GetStaticPath()),
                RequestPath  = "/static"
            });

            (byte[] ret, Error err) = Shared.File.Read(AppPath.GetAppPath() + "/data/ui/index.html");


            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGet("/", async context =>
                {
                    await context.Response.WriteAsync(Encoding.UTF8.GetString(ret, 0, ret.Length));
                });
            });
        }