File: main.cpp

package info (click to toggle)
tntnet 3.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,488 kB
  • sloc: cpp: 16,636; javascript: 8,109; ansic: 2,189; makefile: 861; sh: 317; xml: 258; perl: 159; sql: 14
file content (35 lines) | stat: -rw-r--r-- 669 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <tnt/tntnet.h>

#include <cxxtools/xml/xml.h>

#include <iostream>
#include <fstream>

int main(int argc, char* argv[])
{
    try
    {
        std::ifstream in("@PROJECT@.xml");
        tnt::TntConfig config;
        in >> cxxtools::xml::Xml(config);

        tnt::Tntnet app(config);

        // map static resources
        app.mapUrl("^/(.*)", "resources")
           .setPathInfo("resources/$1");

        // map / to @PROJECT@
        app.mapUrl("^/$", "@PROJECT@");

        // map /comp to comp
        app.mapUrl("^/(.*)", "$1");

        app.run();
    }
    catch (const std::exception& e)
    {
        std::cerr << e.what() << std::endl;
    }
}