Exemplo n.º 1
0
        public static void Test()
        {
            string code = @"<!DOCTYPE html>
            <html>
            <head>
            <meta charset='UTF-8'>
            <Title>Test</Title>
            </head>
            <body>
                <h1>Test Template Engine</h1>
                <i>{{ @DateTime.Now }}</i>
                <p>{{ @req.Method}}</p>
                <p>{{ @req.URL}}</p>
            </body>
            </html>
            ";

            Pink.Templates t    = new Pink.Templates();
            Pink.Template  tmpl = t.fromString("Tryout", MIME.HTML, code);

            Router routes = new Router();

            routes.Add("http://localhost:8080/", tmpl);
            Server s = new Server("http://localhost:8080/", routes);

            s.Start();
            Console.WriteLine("A simple webserver. Press a key to quit.");
            Console.ReadKey();
            s.Stop();
        }
Exemplo n.º 2
0
    //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"));
    }
Exemplo n.º 3
0
        //test server
        public static void Test()
        {
            Router routes = new Router();

            routes.Add("http://localhost:8080/", new DefaultHandler());
            Server s = new Server("http://localhost:8080/", routes);

            s.Start();
            Console.WriteLine("A simple webserver. Press a key to quit.");
            Console.ReadKey();
            s.Stop();
        }
Exemplo n.º 4
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();
    }