1e7006ee57
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
43 lines
935 B
Python
43 lines
935 B
Python
import requests
|
|
import time
|
|
import threading
|
|
import random
|
|
|
|
BASE_URL = 'http://192.168.100.202:30081' # Replace with your actual URL
|
|
|
|
ENDPOINTS = [
|
|
'/hello',
|
|
'/goodbye',
|
|
'/login',
|
|
'/logout',
|
|
'/register',
|
|
'/users',
|
|
'/products',
|
|
'/orders',
|
|
'/cart',
|
|
'/checkout'
|
|
]
|
|
|
|
def simulate_traffic():
|
|
while True:
|
|
endpoint = random.choice(ENDPOINTS)
|
|
url = BASE_URL + endpoint
|
|
try:
|
|
response = requests.get(url)
|
|
print(f"Request to {endpoint} - Status code: {response.status_code}")
|
|
except requests.RequestException as e:
|
|
print(f"Request to {endpoint} failed: {str(e)}")
|
|
|
|
time.sleep(random.uniform(0.1, 0.5))
|
|
|
|
NUM_THREADS = len(ENDPOINTS)
|
|
threads = []
|
|
|
|
for _ in range(NUM_THREADS):
|
|
thread = threading.Thread(target=simulate_traffic)
|
|
threads.append(thread)
|
|
thread.start()
|
|
|
|
for thread in threads:
|
|
thread.join()
|