4 |
4 |
id "Main page root path" root = PACKAGE;
|
5 |
5 |
text "TCP/IP port" port = "8001";
|
6 |
6 |
select("No database", "MySQL", "Postgres", "Sqlite3") "Database" db = 1;
|
|
7 |
option "Use SSE2" sse2 = 1;
|
7 |
8 |
|
8 |
9 |
@@<:PACKAGE:>.h
|
9 |
10 |
#ifndef _<:PACKAGE:>_<:PACKAGE:>_h
|
10 |
11 |
#define _<:PACKAGE:>_<:PACKAGE:>_h
|
11 |
12 |
|
12 |
|
#include <Skylark/Skylark.h>
|
13 |
|
<:?db==1:>#include <MySql/MySql.h><:?db==2:><PostgreSQL/PostgreSQL.h><:?db==3:>#include <plugin/sqlite3/Sqlite3.h>
|
14 |
|
<:.:>
|
|
13 |
#include <Skylark/Skylark.h><:?db==1:>
|
|
14 |
#include <MySql/MySql.h><:?db==2:>
|
|
15 |
#include <PostgreSQL/PostgreSQL.h><:?db==3:>
|
|
16 |
#include <plugin/sqlite3/Sqlite3.h><:.:>
|
15 |
17 |
|
16 |
|
using namespace Upp;
|
|
18 |
using namespace Upp;<:?db:>
|
17 |
19 |
|
18 |
|
<:?db:>#define MODEL <<:PACKAGE:>/Model.sch><:.:>
|
19 |
|
<:?db==1:>#define SCHEMADIALECT <MySql/MySqlSchema.h><:?db==2:>
|
|
20 |
#define MODEL <<:PACKAGE:>/Model.sch><:.:><:?db==1:>
|
|
21 |
#define SCHEMADIALECT <MySql/MySqlSchema.h><:?db==2:>
|
20 |
22 |
#define SCHEMADIALECT <PostgreSQL/PostgreSQLSchema.h><:?db==3:>
|
21 |
|
#define SCHEMADIALECT <plugin/sqlite3/Sqlite3Schema.h><:.:>
|
22 |
|
<:?db:>#include <Sql/sch_header.h><:.:>
|
|
23 |
#define SCHEMADIALECT <plugin/sqlite3/Sqlite3Schema.h><:.:><:?db:>
|
|
24 |
#include <Sql/sch_header.h><:.:>
|
23 |
25 |
|
24 |
26 |
class <:classname:> : public SkylarkApp {
|
25 |
|
public:<:?db:>
|
26 |
|
virtual void WorkThread();
|
27 |
|
<:.:>
|
|
27 |
public:
|
28 |
28 |
typedef <:classname:> CLASSNAME;
|
29 |
|
<:classname:>();
|
|
29 |
<:classname:>();<:?db:>
|
|
30 |
|
|
31 |
virtual void WorkThread();<:.:>
|
30 |
32 |
};
|
31 |
33 |
|
32 |
34 |
#endif
|
... | ... | |
47 |
49 |
{
|
48 |
50 |
http.Redirect(HomePage);
|
49 |
51 |
}
|
50 |
|
|
51 |
52 |
@@Main.cpp
|
52 |
|
#include "<:PACKAGE:>.h"
|
53 |
|
<:?db:>
|
|
53 |
#include "<:PACKAGE:>.h"<:?db:>
|
|
54 |
|
54 |
55 |
#include <Sql/sch_schema.h>
|
55 |
|
#include <Sql/sch_source.h>
|
56 |
|
<:.:>
|
|
56 |
#include <Sql/sch_source.h><:.:>
|
|
57 |
|
57 |
58 |
<:classname:>::<:classname:>()
|
58 |
|
{<:?root:>
|
59 |
|
root = "<:root:>";<:.:>
|
|
59 |
{
|
60 |
60 |
#ifdef _DEBUG
|
61 |
61 |
prefork = 0;
|
62 |
62 |
use_caching = false;
|
63 |
63 |
#endif<:?db==3:>
|
64 |
|
threads = 1; // Sqlite3 does not work well with multiple threads<:.:>
|
|
64 |
threads = 1; // Sqlite3 does not work well with multiple threads<:.:><:?root:>
|
|
65 |
root = "<:root:>";<:.:>
|
65 |
66 |
port = <:port:>;
|
66 |
|
}
|
67 |
|
<:?db==1:>
|
|
67 |
}<:?db==1:>
|
|
68 |
|
68 |
69 |
void OpenSQL(MySqlSession& session)
|
69 |
70 |
{
|
70 |
71 |
// TODO: Fill your connection credentials here:
|
... | ... | |
97 |
98 |
MySqlSession session;
|
98 |
99 |
OpenSQL(session);
|
99 |
100 |
RunThread();
|
100 |
|
}
|
101 |
|
<:?db==2:>
|
|
101 |
}<:?db==2:>
|
|
102 |
|
102 |
103 |
void OpenSQL(PostgreSQLSession& session)
|
103 |
104 |
{
|
104 |
105 |
// TODO: Fill your connection credentials here:
|
... | ... | |
131 |
132 |
PostgreSQLSession session;
|
132 |
133 |
OpenSQL(session);
|
133 |
134 |
RunThread();
|
134 |
|
}
|
135 |
|
<:?db==3:>
|
|
135 |
}<:?db==3:>
|
|
136 |
|
136 |
137 |
void OpenSQL(Sqlite3Session& session)
|
137 |
138 |
{
|
138 |
139 |
if(!session.Open(ConfigFile("db.sqlite3"))) {
|
... | ... | |
164 |
165 |
Sqlite3Session session;
|
165 |
166 |
OpenSQL(session);
|
166 |
167 |
RunThread();
|
167 |
|
}
|
168 |
|
<:.:>
|
|
168 |
}<:.:>
|
169 |
169 |
// After starting the server, enter "127.0.0.1:8001/<:root:>" in your browser
|
170 |
170 |
CONSOLE_APP_MAIN
|
171 |
171 |
{
|
172 |
172 |
#ifdef _DEBUG
|
173 |
173 |
StdLogSetup(LOG_FILE|LOG_COUT);
|
174 |
174 |
Ini::skylark_log = true;
|
175 |
|
#endif
|
176 |
|
<:?db:>InitModel();<:.:>
|
|
175 |
#endif<:?db:>
|
|
176 |
InitModel();<:.:>
|
177 |
177 |
<:classname:>().Run();
|
178 |
178 |
}
|
179 |
|
|
180 |
179 |
@@index.witz
|
181 |
180 |
#include Skylark/Base
|
182 |
181 |
|
... | ... | |
185 |
184 |
#define BODY
|
186 |
185 |
|
187 |
186 |
This is initial home page content of <:PACKAGE:> application.
|
188 |
|
|
189 |
187 |
@@<:PACKAGE:>.upp
|
190 |
188 |
uses
|
191 |
|
Skylark<:?db == 1:>, MySql<:?db == 2:>, PostgreSQL<:?db == 3:>, plugin/sqlite3<:.:>;
|
|
189 |
Skylark<:?db == 1:>,
|
|
190 |
MySql<:?db == 2:>,
|
|
191 |
PostgreSQL<:?db == 3:>,
|
|
192 |
plugin/sqlite3<:.:>;
|
192 |
193 |
|
193 |
194 |
file
|
194 |
195 |
<:PACKAGE:>.h,<:?db:>
|
... | ... | |
198 |
199 |
Main.cpp;
|
199 |
200 |
|
200 |
201 |
mainconfig
|
201 |
|
"" = "MT SSE2";
|
|
202 |
"" = "MT<:?sse2:> SSE2<:.:>";
|