removing each
This commit is contained in:
commit
1c9707b5b8
|
@ -0,0 +1,12 @@
|
|||
<!--tws
|
||||
d = list();
|
||||
d.add(5);
|
||||
d.add(6);
|
||||
d.add("Demi Lovato");
|
||||
each(d)
|
||||
{
|
||||
print item;
|
||||
print "\n";
|
||||
|
||||
}
|
||||
-->
|
|
@ -0,0 +1,8 @@
|
|||
<!--tws
|
||||
print 37 + 1 + 4;
|
||||
-->
|
||||
John
|
||||
<!--tws
|
||||
print "Demi Lovato\n";
|
||||
print "John";
|
||||
-->
|
|
@ -0,0 +1,36 @@
|
|||
#include "tesseswebserver.hpp"
|
||||
TESSESWEBSERVER_STATIC_DECLARATION
|
||||
using namespace Tesses::WebServer;
|
||||
using namespace Tesses::WebServer::ScriptEngine;
|
||||
|
||||
|
||||
int main(int argc,char** argv)
|
||||
{
|
||||
RootEnvironment* rEnv = new RootEnvironment();
|
||||
rEnv->print = [](ScriptType arg)-> void {
|
||||
|
||||
std::cout << ConvertToString(arg);
|
||||
};
|
||||
|
||||
BytecodeCompiler bcc(ScriptParser::Parse("file.twss"));
|
||||
bcc.Compile();
|
||||
auto rf = bcc.file->rootFunction;
|
||||
rf->env = rEnv;
|
||||
rf->isRoot=true;
|
||||
for(auto f : bcc.file->functions)
|
||||
{
|
||||
auto rf2 = f.second;
|
||||
rf2->env = rEnv;
|
||||
rf2->isRoot=false;
|
||||
|
||||
|
||||
|
||||
|
||||
rEnv->SetValue(f.first,ObjectType(f.second));
|
||||
}
|
||||
|
||||
rf->Execute(rEnv,{});
|
||||
|
||||
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,41 @@
|
|||
#include "tesseswebserver.hpp"
|
||||
TESSESWEBSERVER_STATIC_DECLARATION
|
||||
using namespace Tesses::WebServer;
|
||||
using namespace Tesses::WebServer::ScriptEngine;
|
||||
|
||||
class DummyServer : public IServer
|
||||
{
|
||||
public:
|
||||
bool Handle(ServerContext* ctx)
|
||||
{
|
||||
std::string resp = {};
|
||||
|
||||
for(auto param : ctx->queryParams.GetAll())
|
||||
{
|
||||
resp.append(param.first);
|
||||
resp.append(": ");
|
||||
resp.append(param.second);
|
||||
resp.append("\r\n");
|
||||
}
|
||||
|
||||
ctx->SetContentType("text/plain")->SendText(resp);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc,char** argv)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
HttpServerListener::Init();
|
||||
|
||||
IServer* myServer = new DummyServer();
|
||||
|
||||
HttpServerListener::Listen(myServer,3000);
|
||||
|
||||
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#define USE_SCRIPT_ENGINE
|
||||
#define USE_MBEDTLS
|
||||
#define USE_CURL
|
||||
#define USE_SQLITE3
|
||||
#define USE_JANSSON
|
|
@ -0,0 +1,8 @@
|
|||
<!--tws
|
||||
t = post("text");
|
||||
if(t != null)
|
||||
{
|
||||
todos.add(t);
|
||||
}
|
||||
redirect("/");
|
||||
-->
|
|
@ -0,0 +1,3 @@
|
|||
<!--tws
|
||||
free(todos);
|
||||
-->
|
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>ToDo List</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>ToDo List</h1>
|
||||
|
||||
<form method="POST" action="./cgi-bin/add-todo.twss">
|
||||
<input type="text" name="text" placeholder="ToDo Text">
|
||||
<input type="submit" value="Add">
|
||||
</form>
|
||||
|
||||
<ul>
|
||||
<!--tws
|
||||
each(global todos) {
|
||||
-->
|
||||
<li><!--tws print htmlencode(item); --></li>
|
||||
<!--tws
|
||||
}
|
||||
-->
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,3 @@
|
|||
<!--tws
|
||||
todos = list();
|
||||
-->
|
Loading…
Reference in New Issue