Add main.py
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Simple script demonstrating basic functionality.
|
||||||
|
|
||||||
|
This script fetches a public API endpoint and prints the response.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
API_URL = "https://api.github.com"
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
try:
|
||||||
|
response = requests.get(API_URL, timeout=5)
|
||||||
|
response.raise_for_status()
|
||||||
|
data = response.json()
|
||||||
|
print("GitHub API status:", data.get("current_user_url"))
|
||||||
|
except requests.RequestException as e:
|
||||||
|
print("Error fetching API:", e)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user