Finished WWWGen

This commit is contained in:
Mike Nolan 2024-09-23 20:31:12 -05:00
parent 59ba921fd0
commit 6dd5e3a7b7
11 changed files with 54 additions and 5484 deletions

View File

@ -1,11 +0,0 @@
<!--tws
l = list();
l.add(52);
l.add(52);
l.add(69);
each(l)
{
print item;
print "\n";
}
-->

View File

@ -1,8 +0,0 @@
<!--tws
print 37 + 1 + 4;
-->
John
<!--tws
print "Demi Lovato\n";
print "John";
-->

View File

@ -1,37 +0,0 @@
#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

View File

@ -1,41 +0,0 @@
#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

View File

@ -1,7 +0,0 @@
#pragma once
#define USE_SCRIPT_ENGINE
#define USE_MBEDTLS
#define USE_CURL
#define USE_SQLITE3
#define USE_JANSSON

View File

@ -1,8 +1,13 @@
<!--tws <!--tws
t = post("text"); t = query_first("text");
if(t != null)
if(true)
{ {
todos.add(t);
lock();
global todos.add(t);
global save();
unlock();
} }
redirect("/"); redirect("/");
--> -->

View File

@ -1,3 +1,6 @@
<!--tws <!--tws
lock();
print "Freeing todos";
free(todos); free(todos);
unlock();
--> -->

View File

@ -15,11 +15,15 @@
<ul> <ul>
<!--tws <!--tws
var i = 0;
lock();
each(global todos) { each(global todos) {
--> -->
<li><!--tws print htmlencode(item); --></li> <li><!--tws print htmlencode(item); --> <a href="./cgi-bin/delete.twss?id=<!--tws print i; -->">x</a></li>
<!--tws <!--tws
i+=1;
} }
unlock();
--> -->
</ul> </ul>
</body> </body>

View File

@ -1,3 +1,40 @@
<!--tws <!--tws
todos = list(); print "Wake up\n";
lock();
todos = load();
unlock();
func load()
{
var f = fopen("todos.json","rb");
if(f)
{
var len = flength(f);
ba = bytearray(len);
fread(ba,0,len, f);
fclose(f);
var txt = ba.toString();
free(ba);
return JSON_decode(txt);
}
else
{
return list();
}
}
func save()
{
var s = JSON_encode(todos);
var ba = bytearray(s);
var f = fopen("todos.json","wb");
fwrite(ba,0,ba.count(),f);
flength(f);
fclose(f);
free(ba);
}
--> -->