CaesarCloudSync commited on
Commit
130fc9d
1 Parent(s): e3e6ae0

CaesarFinance setup code implemented

Browse files
CaesarAIART/__pycache__/caesaraiart.cpython-39.pyc ADDED
Binary file (1.78 kB). View file
 
CaesarFinance/.env ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ CLIENT_ID="oauth2client_0000ATNK8PJMHBJHwOr7Ef"
2
+ CLIENT_SECRET="mnzconf.aTtNIJGa4WDg+IIRJIwdbEJ9SP1VLOD3om4M0vqvamEzCGK3V4WshwjnKRco2mKOvK0xG0a2tpMVmj2amsrlDw=="
CaesarFinance/caesarfinance.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ from decouple import config
3
+
4
+
5
+ class CaesarFinance:
6
+ def __init__(self) -> None:
7
+ self.CLIENT_ID = config('CLIENT_ID')
8
+ self.CLIENT_SECRET = config('CLIENT_SECRET')
9
+ def create_access_code(self):
10
+ print(f"https://auth.monzo.com/?client_id={self.CLIENT_ID}&redirect_uri=https://palondomus-caesarai.hf.space/caesaraisavecode&response_type=code&state=state_token")
11
+ val = input("Have you created the access code? (y), (n)")
12
+ if val.lower() == "y":
13
+ return True
14
+ elif val.lower() == "n":
15
+ return False
16
+ else:
17
+ return False
18
+
19
+ def fetch_access_code(self):
20
+ resp = requests.get("https://palondomus-caesarai.hf.space/caesaraigetcode")
21
+ return resp.json()
22
+ def get_access_token(self,code):
23
+ url = 'https://api.monzo.com/oauth2/token'
24
+ form_data = {'grant_type': 'value','client_id':self.CLIENT_ID,'client_secret':self.CLIENT_SECRET,
25
+ "redirect_uri":"https://palondomus-caesarai.hf.space",
26
+ "code":code
27
+ }
28
+ server = requests.post(url, data=form_data)
29
+ output = server.text
30
+
31
+ print('The response from the server is: \n', output)
32
+
33
+ if __name__ == "__main__":
34
+ caesarfinance = CaesarFinance()
35
+ access_code_bool = False
36
+ while access_code_bool == False:
37
+ access_code_bool = caesarfinance.create_access_code()
38
+
39
+
40
+ print()
41
+ code = caesarfinance.fetch_access_code()
42
+
43
+ #caesarfinance.get_access_code()
CaesarObjectDetection/__pycache__/CaesarYolo.cpython-39.pyc CHANGED
Binary files a/CaesarObjectDetection/__pycache__/CaesarYolo.cpython-39.pyc and b/CaesarObjectDetection/__pycache__/CaesarYolo.cpython-39.pyc differ
 
__pycache__/RequestModels.cpython-39.pyc CHANGED
Binary files a/__pycache__/RequestModels.cpython-39.pyc and b/__pycache__/RequestModels.cpython-39.pyc differ
 
main.py CHANGED
@@ -54,6 +54,21 @@ def caesaraihome():
54
  @app.get("/caesarailogo")
55
  def caesarailogo():
56
  return FileResponse(f"{CURRENT_DIR}/CaesarAILogo.png")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
  @app.websocket("/caesarobjectdetectws")
59
  async def caesarobjectdetectws(websocket: WebSocket):
 
54
  @app.get("/caesarailogo")
55
  def caesarailogo():
56
  return FileResponse(f"{CURRENT_DIR}/CaesarAILogo.png")
57
+ @app.get("/caesaraisavecode")
58
+ def caesaraisavecode(code: str):
59
+ with open(f"{CURRENT_DIR}/CaesarFinance/current_code.txt","w+") as f:
60
+ f.write(code)
61
+ return {"message":"Temporary fetching code stored."}
62
+ @app.get("/caesaraigetcode")
63
+ def caesaraigetcode():
64
+ if "current_code.txt" in os.listdir(f"{CURRENT_DIR}/CaesarFinance"):
65
+ f = open(f"{CURRENT_DIR}/CaesarFinance/current_code.txt","r")
66
+ code = f.read()
67
+ f.close()
68
+ os.remove(f"{CURRENT_DIR}/CaesarFinance/current_code.txt")
69
+ return {"messagecode":code}
70
+ elif "current_code.txt" not in os.listdir(f"{CURRENT_DIR}/CaesarFinance"):
71
+ return {"message":"temporary code doesn't exist. Please authenticate"}
72
 
73
  @app.websocket("/caesarobjectdetectws")
74
  async def caesarobjectdetectws(websocket: WebSocket):
requirements.txt CHANGED
@@ -117,6 +117,7 @@ typer==0.7.0
117
  typing_extensions==4.5.0
118
  urllib3==1.26.14
119
  uvicorn==0.20.0
 
120
  wasabi==1.1.1
121
  Werkzeug==2.2.3
122
  wincertstore==0.2
 
117
  typing_extensions==4.5.0
118
  urllib3==1.26.14
119
  uvicorn==0.20.0
120
+ python-decouple
121
  wasabi==1.1.1
122
  Werkzeug==2.2.3
123
  wincertstore==0.2