diff --git a/API/rok.py b/API/rok.py index 752a5af..cffd6db 100644 --- a/API/rok.py +++ b/API/rok.py @@ -57,7 +57,7 @@ def download_products(user_name): print("Каталог продуктов скачан.") -download_products(user_name) +# download_products(user_name) # get_orders(access_token) @@ -74,7 +74,7 @@ def download_prices(partner_code): print("Каталог цен скачан.") -# download_prices(partner) +download_prices(partner) \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index e3f94ff..89a0392 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,4 +26,4 @@ EXPOSE 8005 # Presuming there is a `my_app` command provided by the project uvicorn main:app --reload -CMD ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8005"] \ No newline at end of file +CMD ["uv", "run", "main.py"] \ No newline at end of file diff --git a/app/__pycache__/routes.cpython-313.pyc b/app/__pycache__/routes.cpython-313.pyc index 517d17f..097773f 100644 Binary files a/app/__pycache__/routes.cpython-313.pyc and b/app/__pycache__/routes.cpython-313.pyc differ diff --git a/app/routes.py b/app/routes.py index d810f0b..c511c49 100644 --- a/app/routes.py +++ b/app/routes.py @@ -1,5 +1,5 @@ from flask import Blueprint -from services.rokky import ones +# from services.rokky import ones main = Blueprint("main", __name__) @@ -11,7 +11,7 @@ def index(): @main.route("/orders", methods=["POST", "GET"]) def index1(): - ones() + # ones() return "Hello GET" @main.route("/sales", methods=["POST", "GET"]) diff --git a/docker-compose.yml b/docker-compose.yml index 587ff4d..6876c3d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,15 +1,15 @@ -version: "3.9" +version: '3.8' services: - api: + web: build: . - container_name: python_uv_app + container_name: flask-dev ports: - - "8000:8000" - + - "5000:5000" # Пробрасываем порт наружу volumes: - - ./app:/app - - restart: always - -command: ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8005"] \ No newline at end of file + # Главная строка: монтируем текущую папку с кодом (.) + # в папку /app внутри контейнера + - .:/app + environment: + - FLASK_DEBUG=1 # Дополнительная страховка для включения дебага + - PYTHONUNBUFFERED=1 # Чтобы логи выводились сразу, а не кэшировались \ No newline at end of file diff --git a/main.py b/main.py index 31d23d3..97be195 100644 --- a/main.py +++ b/main.py @@ -5,4 +5,4 @@ app = create_app() start_scheduler() if __name__ == "__main__": - app.run(host="0.0.0.0", port=5000, debug=True) \ No newline at end of file + app.run(host="0.0.0.0", port=5205, debug=True) \ No newline at end of file diff --git a/services/__pycache__/rokky.cpython-313.pyc b/services/__pycache__/rokky.cpython-313.pyc index 0ba56ea..a6b467f 100644 Binary files a/services/__pycache__/rokky.cpython-313.pyc and b/services/__pycache__/rokky.cpython-313.pyc differ diff --git a/services/gg.py b/services/gg.py index d26d8bb..f5bbca2 100644 --- a/services/gg.py +++ b/services/gg.py @@ -128,7 +128,92 @@ def last_sales(top=10, group=False): return r.json() -print(last_sales()) +# print(last_sales()) + +def get_messages(id_i, id_from=None, id_to=None, newer=None, count=50): + token = load_token() + + if not token: + token = get_token() + + url = "https://seller.ggsel.com/api_sellers/api/debates/v2" + + headers = { + "Accept": "application/json" + } + + params = { + "token": token, + "id_i": id_i, + "count": min(count, 100) + } + + if id_from: + params["id_from"] = id_from + + if id_to: + params["id_to"] = id_to + + if newer: + params["newer"] = newer + + r = requests.get(url, params=params, headers=headers) + print(r.status_code) + + # если токен умер + if r.status_code in (401, 403): + token = get_token() + params["token"] = token + r = requests.get(url, params=params, headers=headers) + + return r.json() + + +# пример +print(get_messages(id_i=18840912)) + + +def get_chats(page=1, pagesize=20, filter_new=None, email=None, id_ds=None): + token = load_token() + + if not token: + token = get_token() + + url = "https://seller.ggsel.com/api_sellers/api/debates/v2/chats" + + headers = { + "Accept": "application/json" + } + + params = { + "token": token, + "page": page, + "pagesize": pagesize + } + + if filter_new is not None: + params["filter_new"] = filter_new + + if email: + params["email"] = email + + if id_ds: + params["id_ds"] = id_ds + + r = requests.get(url, params=params, headers=headers) + print(r.status_code) + + # если токен умер + if r.status_code in (401, 403): + token = get_token() + params["token"] = token + r = requests.get(url, params=params, headers=headers) + + return r.json() + + +# пример +# print(get_chats()) # def tokens(): # timestamp = str(int(time.time())) diff --git a/services/rokky.py b/services/rokky.py index f65c7b1..1d878d5 100644 --- a/services/rokky.py +++ b/services/rokky.py @@ -47,17 +47,17 @@ def decrypt_file(input_file, output_file, password): decrypt_file( - "./files/products.json.gz.enc", - "./files/products.json.gz", + "./files/prices.json.gz.enc", + "./files/prices.json.gz", password ) def archive(): - with gzip.open("./files/products.json.gz", "rb") as f_in: - with open("./files/products.json", "wb") as f_out: + with gzip.open("./files/prices.json.gz", "rb") as f_in: + with open("./files/prices.json", "wb") as f_out: shutil.copyfileobj(f_in, f_out) archive() -with open("./files/products.json", "r", encoding="utf-8") as f: +with open("./files/prices.json", "r", encoding="utf-8") as f: products = json.load(f) def get_title(product, lang="RU"): @@ -152,5 +152,5 @@ def update_prices(conn): conn.commit() - +# add_product() update_prices(conn) \ No newline at end of file