Python Help

The.One

Active member
  • Dec 20, 2020
    197
    212
    43
    Uganda
    1.
    Untitled.png


    2.
    Untitled1.png



    මචං, මේ දෙකට උත්තර දන්නවා නම් කියපන්. තෙරෙන්නේ නෑ කරන්න.
     

    Khonshu

    Well-known member
  • Apr 28, 2022
    347
    454
    63
    Egypt
    1. හරිද දන්නෙනම් නැ. මාත් තාම beginner
    Code:
    import requests
    
    url = "http://host1.open.uom.lk:8080"
    response = requests.get(f"{url}/api/products/")
    data = response.json()["data"]
    
    for i in range(0, len(data)):
        print(data[i])
    print(f"Total number of products: {len(data)}")
     

    The.One

    Active member
  • Dec 20, 2020
    197
    212
    43
    Uganda
    1. හරිද දන්නෙනම් නැ. මාත් තාම beginner
    Code:
    import requests
    
    url = "http://host1.open.uom.lk:8080"
    response = requests.get(f"{url}/api/products/")
    data = response.json()["data"]
    
    for i in range(0, len(data)):
        print(data[i])
    print(f"Total number of products: {len(data)}")

    Ado thanks machan, wade hari
     
    • Like
    Reactions: Khonshu

    P. Ananda

    Member
    Jan 27, 2013
    1
    0
    1
    import requests

    BASE_URL = 'http://host1.open.uom.lk:8080'

    updated_entity = {
    "productName": "Araliya Basmathi Rice",
    "description": "White Basmathi Rice imported from Pakistan. High-quality rice with extra fragrance. Organically grown.",
    "category": "Rice",
    "brand": "Araliya",
    "expiredDate": "2023.05.04",
    "manufacturedDate": "2022.02.20",
    "batchNumber": 324567,
    "unitPrice": 1020,
    "quantity": 200,
    "createdDate": "2022.02.24"
    }

    response = requests.put(f"{BASE_URL}/api/products", json=updated_entity)
    print(response.json())

    1. හරිද දන්නෙනම් නැ. මාත් තාම beginner
    Code:
    import requests
    
    url = "http://host1.open.uom.lk:8080"
    response = requests.get(f"{url}/api/products/")
    data = response.json()["data"]
    
    for i in range(0, len(data)):
        print(data[i])
    print(f"Total number of products: {len(data)}")

    import requests

    BASE_URL = 'http://host1.open.uom.lk:8080'

    create_entity = {
    "productName": "Araliya Basmathi Rice",
    "description": "White Basmathi Rice imported from Pakistan. High-quality rice with extra fragrance. Organically grown.",
    "category": "Rice",
    "brand": "CIC",
    "expiredDate": "2023.05.04",
    "manufacturedDate": "2022.02.20",
    "batchNumber": 324567,
    "unitPrice": 1020,
    "quantity": 200,
    "createdDate": "2022.02.24"
    }

    response = requests.post(f"{BASE_URL}/api/products", json=create_entity)
    print(response.status_code)
    ------ Post added on Jun 18, 2023 at 11:01 AM
     

    siri_ayya

    Well-known member
  • Feb 1, 2022
    16,966
    1
    29,883
    113
    Chatgpt, bard වගේ ටූල්ස් try කරන්න මේවට හොදට උත්තර දෙනවා ඒවායින්..