Добавил возможность смены картинки при нажатии на картинку
This commit is contained in:
parent
9dbcc53fd1
commit
0d782ec32e
5 changed files with 1051 additions and 8 deletions
|
@ -2,9 +2,13 @@ FROM golang:1.22-alpine
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY ./main.html /app/main.html
|
COPY ./index.html /app/index.html
|
||||||
|
|
||||||
COPY ./static /app/static
|
COPY ./src /app/src
|
||||||
|
|
||||||
|
COPY ./package.json /app/package.json
|
||||||
|
|
||||||
|
RUN apk add --no-cache npm && npm install -D vite && npm install && npm run build
|
||||||
|
|
||||||
VOLUME /app/images
|
VOLUME /app/images
|
||||||
|
|
||||||
|
|
1
main.go
1
main.go
|
@ -33,6 +33,7 @@ func GetRandImg() string {
|
||||||
|
|
||||||
func ReturnPicFilename(w http.ResponseWriter, req *http.Request) {
|
func ReturnPicFilename(w http.ResponseWriter, req *http.Request) {
|
||||||
var picFilename io.Reader = strings.NewReader(GetRandImg())
|
var picFilename io.Reader = strings.NewReader(GetRandImg())
|
||||||
|
log.Println("Картинка отдана")
|
||||||
io.Copy(w, picFilename)
|
io.Copy(w, picFilename)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1036
package-lock.json
generated
Normal file
1036
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -9,7 +9,7 @@
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite": "^6.0.1",
|
"axios": "1.7.9",
|
||||||
"axios": "1.7.9"
|
"vite": "^6.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,9 @@
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
let pictureId = document.getElementById("CatGirlPicture")
|
let pictureId = document.getElementById("CatGirlPicture");
|
||||||
pictureId.onclick = function() {
|
pictureId.onclick = function() {
|
||||||
let picFilename = axios.get(location.href + "rand")
|
axios.get(location.href + "rand").then(function (response) {
|
||||||
console.log(picFilename)
|
console.log(response.data)
|
||||||
|
document.getElementById("CatGirlPicture").setAttribute("src", "images/"+response.data);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue