mirror of
https://github.com/Llloooggg/TextSouls.git
synced 2026-03-06 04:26:23 +03:00
29 lines
750 B
Python
29 lines
750 B
Python
import json
|
|
import requests
|
|
|
|
with open("textsouls/config.json") as config_file:
|
|
config_data = json.load(config_file)
|
|
|
|
|
|
class Backend:
|
|
base_url = config_data["BACKEND_SETTINGS"]["BASE_URL"]
|
|
|
|
def get(self, relative_url):
|
|
try:
|
|
response = requests.get(f"{self.base_url}{relative_url}")
|
|
return {"error": None, "response": response}
|
|
except Exception as err:
|
|
return {"error": err}
|
|
|
|
def post(self, relative_url, data):
|
|
try:
|
|
response = requests.post(
|
|
f"{self.base_url}{relative_url}", json=data
|
|
)
|
|
return {"error": None, "response": response}
|
|
except Exception as err:
|
|
return {"error": err}
|
|
|
|
|
|
backend = Backend()
|