@@ -188,12 +188,16 @@ local function enqueueCommand(args, id, outputFile)
188
188
return promise
189
189
end
190
190
191
+ -- HTTP contexts used by the web application
192
+ local httpContexts = {
193
+ [' /(.*)' ] = FileHttpHandler :new (File :new (scriptDir , ' htdocs' ), nil , ' fcut.html' ),
194
+ [' /config/(.*)' ] = TableHttpHandler :new (config , nil , true ),
195
+ [' /assets/(.*)' ] = assetsHandler ,
196
+ }
197
+
191
198
-- Create the HTTP contexts used by the web application
192
199
local function createHttpContexts (httpServer )
193
200
logger :info (' HTTP Server bound on port ' .. tostring (select (2 , httpServer :getAddress ())))
194
- httpServer :createContext (' /(.*)' , FileHttpHandler :new (File :new (scriptDir , ' htdocs' ), nil , ' fcut.html' ))
195
- httpServer :createContext (' /config/(.*)' , TableHttpHandler :new (config , nil , true ))
196
- httpServer :createContext (' /assets/(.*)' , assetsHandler )
197
201
-- Context to retrieve and cache a movie image at a specific time
198
202
httpServer :createContext (' /source/([^/]+)/(%d+)%.jpg' , Map .assign (FileHttpHandler :new (cacheDir ), {
199
203
getPath = function (_ , exchange )
344
348
if config .webview .disable then
345
349
local httpServer = require (' jls.net.http.HttpServer' ):new ()
346
350
httpServer :bind (config .webview .address , config .webview .port ):next (function ()
351
+ for path , handler in pairs (httpContexts ) do
352
+ httpServer :createContext (path , handler )
353
+ end
347
354
createHttpContexts (httpServer )
348
355
if config .webview .port == 0 then
349
356
print (' FCut HTTP Server available at http://localhost:' .. tostring (select (2 , httpServer :getAddress ())))
366
373
resizable = true ,
367
374
bind = true ,
368
375
debug = config .webview .debug ,
376
+ contexts = httpContexts ,
369
377
}):next (function (webview )
370
378
local httpServer = webview :getHttpServer ()
371
379
createHttpContexts (httpServer )
0 commit comments