25 lines
772 B
Python
25 lines
772 B
Python
import requests
|
|
import time
|
|
|
|
def test_flask_server():
|
|
"""Test if the Flask server is accessible at http://127.0.0.1:5000"""
|
|
url = "http://127.0.0.1:5000"
|
|
|
|
print(f"Testing connection to Flask server at {url}")
|
|
|
|
for i in range(3):
|
|
try:
|
|
response = requests.get(url, timeout=5)
|
|
print(f"SUCCESS! Status code: {response.status_code}")
|
|
return True
|
|
except requests.exceptions.RequestException as e:
|
|
print(f"Attempt {i+1} failed: {e}")
|
|
if i < 2:
|
|
print("Waiting 2 seconds and trying again...")
|
|
time.sleep(2)
|
|
|
|
print("Failed to connect to the Flask server after 3 attempts")
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
test_flask_server() |