Serving one hardcoded image

This commit is contained in:
Senad Uka
2023-03-04 11:45:53 +01:00
parent 10492ad1bc
commit 36580d308f
9 changed files with 70 additions and 21 deletions

2
.gitignore vendored
View File

@@ -19,3 +19,5 @@
# Dependency directories (remove the comment below to include it) # Dependency directories (remove the comment below to include it)
# vendor/ # vendor/
.idea/

View File

@@ -1,8 +1,8 @@
package main package main
import "github.com/edazdarevic/reklame/agent/internal/app/telal" import "reklame-agent/internal/app/telal"
// create a main function that calls ServeAds from the telal package // create a main function that calls ServeAds from the telal package
func main() { func main() {
telal.ServeAds() telal.ServeBanners()
} }

6
go.mod
View File

@@ -1,5 +1,5 @@
module github.com/saburly/reklame-agent/ module reklame-agent
go 1.14 go 1.20
require github.com/gorilla/websocket v1.5.0 require github.com/gorilla/websocket v1.5.0 // indirect

File diff suppressed because one or more lines are too long

View File

@@ -1,3 +0,0 @@
module github.com/gorilla/websocket
go 1.12

View File

2
vendor/modules.txt vendored
View File

@@ -1,3 +1,3 @@
# github.com/gorilla/websocket v1.5.0 # github.com/gorilla/websocket v1.5.0
## explicit ## explicit; go 1.12
github.com/gorilla/websocket github.com/gorilla/websocket

40
web/static/index.html Normal file
View File

@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<title>WebSocket Image Background</title>
<style>
/* Set margin and padding to zero to fill the entire page with the background */
html, body {
margin: 0;
padding: 0;
}
/* Stretch the background image to cover the entire page */
body {
background-image: url(http://localhost:8082/image.jpg);
background-size: cover;
background-repeat: no-repeat;
}
</style>
</head>
<body>
<script>
// Create a WebSocket connection to the server
const ws = new WebSocket('ws://localhost:8081/ws');
// When a message is received from the server
ws.onmessage = function(event) {
// Parse the message as JSON
const message = JSON.parse(event.data);
// Check if the message contains an image URL
if (message.type === 'image' && message.url) {
// Set the body background to the image URL
document.body.style.backgroundImage = `url(${message.url})`;
}
};
</script>
</body>
</html>

View File

@@ -1,8 +0,0 @@
# `/website`
This is the place to put your project's website data if you are not using GitHub pages.
Examples:
* https://github.com/hashicorp/vault/tree/master/website
* https://github.com/perkeep/perkeep/tree/master/website