示例#1
0
文件: test.cs 项目: bennof/pinkserver
    //string URL = "http://*****:*****@".\priv\db\example.accdb"));
        DB.Start();

        // setup static handler
        Pink.StaticFileHandler staticHandler = new Pink.StaticFileHandler(@".\priv\static");
        routes.Add("http://*****:*****@".\priv\tmpl\article.html"));
        routes.Add("http://*****:*****@".\priv\tmpl\editor.html"));
        routes.Add("http://*****:*****@".\priv\tmpl\index.html"));
    }
示例#2
0
    public void Init()
    {
        Console.WriteLine("Read Config ...");
        Config cfg = Config.Read(@".cfg");

        // helper to check config
        foreach (KeyValuePair <string, string> kv in cfg)
        {
            Console.WriteLine(">>> " + kv.Key + " = " + kv.Value);
        }

        Console.WriteLine("Open DB ...");
        // DB connection
        string provider = Pink.DB.GetProvider("ACE");

        if (provider == null)
        {
            Console.WriteLine("Error: No ACE Provider"); return;
        }
        db = Pink.DB.Connect(provider, cfg["Database"]);
        DB = new Pink.DBServer(db);
        DB.Start();

        Console.WriteLine("Start Webserver ... ");

        staticHandler = new Pink.StaticFileHandler(cfg["StaticFiles"]);
        //routes.Add(cfg["Server"]+"index.html", staticHandler);
        routes.Add(cfg["Server"] + "img/", staticHandler);
        routes.Add(cfg["Server"] + "css/", staticHandler);
        routes.Add(cfg["Server"] + "js/", staticHandler);
        routes.Add(cfg["Server"] + "favicon.ico", staticHandler);
        routes.Add(cfg["Server"] + "schild/", this);
        routes.Add(cfg["Server"] + "index.html", tmpl.fromFile("INDEX", cfg["IndexFile"]));

        srv = new Pink.Server(cfg["Server"], routes);
        srv.Start();
    }