1 Commits

Author SHA1 Message Date
dfbe5da4be Test 2025-02-27 11:51:59 -03:00
3 changed files with 10 additions and 31 deletions

View File

@@ -1,31 +0,0 @@
FROM node:latest
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
golang-go
# Copy project directories
COPY frontend /app/frontend
COPY backend /app/backend
COPY yoomoney_src /app/yoomoney_src
WORKDIR /app/frontend/style
# Install Next.js and react-wavify
RUN npm install next --force && \
npm install react-wavify --force
# Start npm in background
CMD nohup npm run dev &
# Change to yoomoney_src directory and install Python dependencies
WORKDIR /app/yoomoney_src
RUN pip3 install -r requirements.txt --break-system-packages
# Run main.py in background
CMD nohup python3 main.py &
# Change to backend/api directory and run main.go
WORKDIR /app/backend/api
CMD nohup go run main.go &
# Change to backend/review directory and run main.go
WORKDIR /app/frontend/style/components
CMD nohup go run main.go &
EXPOSE 3000
CMD ["/bin/bash"]

BIN
backend/api/main Executable file

Binary file not shown.

View File

@@ -77,6 +77,7 @@ func initDB() {
/*----------------------------PAYMENT--------------------------------------*/
func payHandler(w http.ResponseWriter, r *http.Request) {
fmt.Println("PAY HERE, BABY!")
// Структура для тела запроса на localhost:5000
type PaymentRequest struct {
ID string `json:"id"`
@@ -91,6 +92,11 @@ func payHandler(w http.ResponseWriter, r *http.Request) {
cookie, err := r.Cookie("totalPrice")
if err != nil {
fmt.Println("Не удалось получить amount из cookies")
fmt.Println("\nPrinting all cookies")
for _, c := range r.Cookies() {
fmt.Println(c)
}
http.Error(w, "Не удалось получить amount из cookies", http.StatusBadRequest)
return
}
@@ -98,6 +104,7 @@ func payHandler(w http.ResponseWriter, r *http.Request) {
// Преобразуем amount из строки в float64
amount, err := strconv.ParseFloat(cookie.Value, 64)
if err != nil {
fmt.Println("Некорректное значение amount в cookies")
http.Error(w, "Некорректное значение amount в cookies", http.StatusBadRequest)
return
}
@@ -113,6 +120,7 @@ func payHandler(w http.ResponseWriter, r *http.Request) {
// Преобразуем тело запроса в JSON
requestBody, err := json.Marshal(paymentRequest)
if err != nil {
fmt.Println("Ошибка при создании запроса")
http.Error(w, "Ошибка при создании запроса", http.StatusInternalServerError)
return
}
@@ -120,6 +128,7 @@ func payHandler(w http.ResponseWriter, r *http.Request) {
// Отправляем POST-запрос на localhost:5000
resp, err := http.Post("http://localhost:5000/pay", "application/json", bytes.NewBuffer(requestBody))
if err != nil {
fmt.Println("Ошибка при отправке запроса на сервер")
http.Error(w, "Ошибка при отправке запроса на сервер", http.StatusInternalServerError)
return
}
@@ -128,6 +137,7 @@ func payHandler(w http.ResponseWriter, r *http.Request) {
// Читаем ответ от сервера
var paymentResponse PaymentResponse
if err := json.NewDecoder(resp.Body).Decode(&paymentResponse); err != nil {
fmt.Println("Ошибка при чтении ответа от сервера")
http.Error(w, "Ошибка при чтении ответа от сервера", http.StatusInternalServerError)
return
}