From 67df647fb28c1d670e3208f5ef56402578301265 Mon Sep 17 00:00:00 2001 From: Mike Nolan Date: Mon, 23 Sep 2024 20:54:06 -0500 Subject: [PATCH] Finished WWWGen --- src/tesseswebserver.hpp | 7 +++++++ wwwgen.cpp | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/tesseswebserver.hpp b/src/tesseswebserver.hpp index 432bfb2..0f81254 100644 --- a/src/tesseswebserver.hpp +++ b/src/tesseswebserver.hpp @@ -1060,6 +1060,7 @@ class StaticServer : public IServer { #if defined(USE_SCRIPT_ENGINE) ScriptEngine::RootEnvironment* env; ScriptEngine::BytecodeFile* initFile; + #endif std::filesystem::path dir; bool allowListing; @@ -1173,6 +1174,12 @@ class StaticServer : public IServer { Init(dir,allowListing,allowScript,std::vector({"index.html","index.htm","default.html","default.htm"})); } + #if defined(USE_SCRIPT_ENGINE) + ScriptEngine::RootEnvironment* GetRootEnvironment() + { + return this->env; + } + #endif bool Handle(ServerContext* ctx) { auto path=sanitise(ctx->path); diff --git a/wwwgen.cpp b/wwwgen.cpp index 6adf679..c9693a4 100644 --- a/wwwgen.cpp +++ b/wwwgen.cpp @@ -427,6 +427,10 @@ int main(int argc,char** argv) cls.append("\n#endif\n"); } cls.append("}"); + if(enableScripts) + { + cls.append("\n#if defined(USE_SCRIPT_ENGINE)\nTesses::WebServer::ScriptEngine::RootEnvironment* GetRootEnvironment(){return this->env;}\n#endif\n"); + } cls.append("bool Handle(Tesses::WebServer::ServerContext* ctx){auto path=sanitise(ctx->path); int index = get_file(path); if(index == -1) return false;");