# fetch_data.py # Made by user333_ # Meant to be included with main.py from requests import post, get from sys import exit def fetch_data(url: str, json: dict, request_type: str) -> dict: if request_type == "post": try: data = post(url = url, json = json) return data.json() except Exception as e: NetworkError(e) if request_type == "get": try: data = get(url = url) return data.json() except Exception as e: NetworkError(e) def NetworkError(e: str): raise Exception(f"""[ERROR] Error 1: An exception occured while attempting to fetch data. This could be a result of an invalid request, no network connection, or the server is offline. Exception: {e}""") exit(1) if __name__ == "__main__": raise Exception("[ERROR] You ran the wrong script, run main.py instead.") exit(1)