Serving one hardcoded image
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -19,3 +19,5 @@
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
|
||||
.idea/
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
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
|
||||
func main() {
|
||||
telal.ServeAds()
|
||||
telal.ServeBanners()
|
||||
}
|
||||
|
||||
6
go.mod
6
go.mod
@@ -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
3
vendor/github.com/gorilla/websocket/go.mod
generated
vendored
3
vendor/github.com/gorilla/websocket/go.mod
generated
vendored
@@ -1,3 +0,0 @@
|
||||
module github.com/gorilla/websocket
|
||||
|
||||
go 1.12
|
||||
0
vendor/github.com/gorilla/websocket/go.sum
generated
vendored
0
vendor/github.com/gorilla/websocket/go.sum
generated
vendored
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@@ -1,3 +1,3 @@
|
||||
# github.com/gorilla/websocket v1.5.0
|
||||
## explicit
|
||||
## explicit; go 1.12
|
||||
github.com/gorilla/websocket
|
||||
|
||||
40
web/static/index.html
Normal file
40
web/static/index.html
Normal 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>
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user