.Skylark tutorial

git-svn-id: svn://ultimatepp.org/upp/trunk@5141 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2012-07-06 16:16:23 +00:00
parent 85e3814e3f
commit 81e10147be
4 changed files with 72 additions and 0 deletions

View file

@ -0,0 +1,13 @@
description "Session\377";
uses
Core,
Skylark;
file
index.witz,
main.cpp;
mainconfig
"" = "SSE2 MT";

View file

@ -0,0 +1,15 @@
<html>
<body>
<form action=$Submit method="post" accept-charset="utf-8" enctype="multipart/form-data">
<P>
$post_identity()
<INPUT type="text" name="id">
<INPUT type="submit" value="Add to list">
</P>
</form>
List ($count(LIST)):<br>
$for(i in LIST)
"$i"
$endfor
</body>
</html>

5
tutorial/Skylark07/init Normal file
View file

@ -0,0 +1,5 @@
#ifndef _Skylark07_icpp_init_stub
#define _Skylark07_icpp_init_stub
#include "Core/init"
#include "Skylark/init"
#endif

View file

@ -0,0 +1,39 @@
#include <Skylark/Skylark.h>
using namespace Upp;
SKYLARK(HomePage, "")
{
http.RenderResult("Skylark07/index");
}
SKYLARK(Submit, "submit:POST")
{
Value h = http["LIST"];
ValueArray va;
if(IsValueArray(h))
va = h;
va.Add(http["id"]);
http.SessionSet("LIST", va);
http.Redirect(HomePage);
}
struct MyApp : SkylarkApp {
MyApp() {
root = "myapp";
#ifdef _DEBUG
prefork = 0;
use_caching = false;
#endif
}
};
CONSOLE_APP_MAIN
{
#ifdef _DEBUG
StdLogSetup(LOG_FILE|LOG_COUT);
Ini::skylark_log = true;
#endif
MyApp().Run();
}