aboutsummaryrefslogtreecommitdiff
path: root/hsm-web
diff options
context:
space:
mode:
Diffstat (limited to 'hsm-web')
-rw-r--r--hsm-web/Hsm/Web.hs28
-rw-r--r--hsm-web/Html/index.html22
-rw-r--r--hsm-web/Main.hs5
-rw-r--r--hsm-web/hsm-web.cabal6
4 files changed, 12 insertions, 49 deletions
diff --git a/hsm-web/Hsm/Web.hs b/hsm-web/Hsm/Web.hs
index 8c0284c..aaf67d2 100644
--- a/hsm-web/Hsm/Web.hs
+++ b/hsm-web/Hsm/Web.hs
@@ -9,21 +9,13 @@ module Hsm.Web
where
import Effectful (Dispatch (Static), DispatchOf, Eff, IOE, (:>))
-import Effectful.Dispatch.Static
- ( SideEffects (WithSideEffects)
- , StaticRep
- , evalStaticRep
- , getStaticRep
- , unEff
- , unsafeEff
- )
+import Effectful.Dispatch.Static (SideEffects (WithSideEffects), StaticRep, evalStaticRep, getStaticRep, unsafeEff)
import Effectful.Dispatch.Static.Primitive (Env)
import Effectful.Exception (finally)
-import Hsm.Cam (Cam, capturePng)
import Hsm.Log (Log, Logs, Severity (Info, Trace), logMsg, makeLoggerIO)
import Network.Wai.Handler.Warp (defaultSettings, setLogger)
import Paths_hsm_web (getDataFileName)
-import Web.Scotty (Options (settings, verbose), defaultOptions, file, get, liftIO, raw, scottyOpts, setHeader)
+import Web.Scotty (Options (settings, verbose), defaultOptions, file, get, scottyOpts)
data Web (a :: * -> *) (b :: *)
@@ -32,23 +24,17 @@ type instance DispatchOf Web = Static WithSideEffects
newtype instance StaticRep Web
= Web Options
-server :: (Cam :> es, Log "cam" :> es) => Options -> Env es -> IO ()
-server options env = do
- index <- getDataFileName "Html/index.html"
- scottyOpts options $ do
- get "/" $ file index
- get "/cam.png" $ do
- setHeader "Content-Type" "image/png"
- liftIO (unEff capturePng env) >>= raw
+server :: Options -> Env es -> IO ()
+server options _ = getDataFileName "Html/index.html" >>= scottyOpts options . get "/" . file
-runServer :: (Cam :> es, Logs '["cam", "web"] es, Web :> es) => Eff es ()
+runServer :: (Log "web" :> es, Web :> es) => Eff es ()
runServer = finally startServer stopServer
where
startServer = do
Web options <- getStaticRep
- logMsg @"web" Info "Starting scotty web server"
+ logMsg Info "Starting scotty web server"
unsafeEff $ server options
- stopServer = logMsg @"web" Info "Stopping scotty web server"
+ stopServer = logMsg Info "Stopping scotty web server"
runWeb :: (IOE :> es, Logs '["scotty", "web"] es) => Eff (Web : es) a -> Eff es a
runWeb action = do
diff --git a/hsm-web/Html/index.html b/hsm-web/Html/index.html
index 814f6e7..60ec1a3 100644
--- a/hsm-web/Html/index.html
+++ b/hsm-web/Html/index.html
@@ -5,19 +5,9 @@
<meta charset="utf-8"/>
</head>
<body>
- <img id="cam_view" />
+ <h1>HsMouse</h1>
</body>
<script>
- updateImg = () => {
- fetch("cam.png")
- .then(response => response.blob())
- .then(function(myBlob){
- URL.revokeObjectURL(cam_view.src)
- cam_view.src = URL.createObjectURL(myBlob)
- updateImg()
- })
- }
- updateImg()
</script>
<style>
body, html {
@@ -28,15 +18,5 @@
margin: 0;
position: relative;
}
- #cam_view {
- left: 50%;
- margin: auto;
- max-height: calc(100% - 20px);
- max-width: calc(100% - 20px);
- outline: 2px solid #586e75;
- position: absolute;
- top: 10px;
- transform: translate(-50%, 0);
- }
</style>
</html>
diff --git a/hsm-web/Main.hs b/hsm-web/Main.hs
index 82e07c9..7555067 100644
--- a/hsm-web/Main.hs
+++ b/hsm-web/Main.hs
@@ -2,7 +2,6 @@
import Data.Function ((&))
import Effectful (runEff)
-import Hsm.Cam (runCam)
import Hsm.Core.App (bootstrapAppNoEcho)
import Hsm.Log (Severity (Info), runLogsOpt)
import Hsm.Log.Options (makeLoggerOptionParser)
@@ -11,9 +10,9 @@ import Hsm.Web (runServer, runWeb)
-- Avoids package/module qualifiers in generated code
import Options.Applicative
-type Logs = '["cam", "libcamera", "scotty", "web"]
+type Logs = '["scotty", "web"]
$(makeLoggerOptionParser @Logs "Options" "parser" 'Info)
main :: IO ()
-main = bootstrapAppNoEcho parser "Launch HsMouse Web Server" $ \opts -> runServer & runWeb & runCam & runLogsOpt @Options @Logs opts & runEff
+main = bootstrapAppNoEcho parser "Launch HsMouse Web Server" $ \opts -> runServer & runWeb & runLogsOpt @Options @Logs opts & runEff
diff --git a/hsm-web/hsm-web.cabal b/hsm-web/hsm-web.cabal
index ca631b4..f0d03fa 100644
--- a/hsm-web/hsm-web.cabal
+++ b/hsm-web/hsm-web.cabal
@@ -9,7 +9,6 @@ library
, base
, effectful-core
, effectful-plugin
- , hsm-cam
, hsm-log
, scotty
, warp
@@ -27,7 +26,6 @@ executable hsm-web
, base
, effectful-core
, effectful-plugin
- , hsm-cam
, hsm-core
, hsm-log
, optparse-applicative
@@ -36,8 +34,8 @@ executable hsm-web
default-language: GHC2024
ghc-options:
- -O2 -threaded -Wall -Werror -Wno-star-is-type -Wunused-packages -Wno-unused-imports
- -ddump-splices -fplugin=Effectful.Plugin
+ -O2 -threaded -Wall -Werror -Wno-star-is-type -Wunused-packages
+ -Wno-unused-imports -ddump-splices -fplugin=Effectful.Plugin
if !arch(x86_64)
ghc-options: -optl=-mno-fix-cortex-a53-835769