Skip to content

Commit 727f603

Browse files
Fix page not available on webview
1 parent 8d83c38 commit 727f603

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## What is Fast Cut?
22

3-
Fast Cut allows to visually cut and join videos then export losslessly.
3+
Fast Cut allows to visually cut and join videos then export them losslessly.
44

55
> :warning: The project is still experimental.
66

fcut.lua

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,16 @@ local function enqueueCommand(args, id, outputFile)
188188
return promise
189189
end
190190

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+
191198
-- Create the HTTP contexts used by the web application
192199
local function createHttpContexts(httpServer)
193200
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)
197201
-- Context to retrieve and cache a movie image at a specific time
198202
httpServer:createContext('/source/([^/]+)/(%d+)%.jpg', Map.assign(FileHttpHandler:new(cacheDir), {
199203
getPath = function(_, exchange)
@@ -344,6 +348,9 @@ end
344348
if config.webview.disable then
345349
local httpServer = require('jls.net.http.HttpServer'):new()
346350
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
347354
createHttpContexts(httpServer)
348355
if config.webview.port == 0 then
349356
print('FCut HTTP Server available at http://localhost:'..tostring(select(2, httpServer:getAddress())))
@@ -366,6 +373,7 @@ else
366373
resizable = true,
367374
bind = true,
368375
debug = config.webview.debug,
376+
contexts = httpContexts,
369377
}):next(function(webview)
370378
local httpServer = webview:getHttpServer()
371379
createHttpContexts(httpServer)

0 commit comments

Comments
 (0)