Arafath10 commited on
Commit
3d7db0c
1 Parent(s): b4aeb04

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +10 -10
main.py CHANGED
@@ -6,7 +6,7 @@ from fastapi.middleware.cors import CORSMiddleware
6
  from io import StringIO
7
  import os
8
  import uuid
9
- # from apscheduler.schedulers.background import BackgroundScheduler
10
 
11
  # import googletrans
12
  # from googletrans import Translator
@@ -36,10 +36,10 @@ import base64
36
  from PIL import Image
37
  from io import BytesIO
38
 
39
- @app.post("/translator")
40
- async def tra(sentence,lang):
41
- lang = lang.lower()
42
- return translator.translate(sentence,dest=keys[vals.index(lang)]).text
43
 
44
  def convert_image_to_base64(image_path):
45
  with Image.open(image_path) as image:
@@ -52,14 +52,14 @@ def convert_image_to_base64(image_path):
52
 
53
 
54
  # # Function to call the endpoint
55
- # def call_my_endpoint():
56
  # #response = requests.get("http://127.0.0.1:8000/my-endpoint")
57
- # print(f"Endpoint response: {response.json()}")
58
 
59
  # # Configure the scheduler
60
- # scheduler = BackgroundScheduler()
61
- # scheduler.add_job(call_my_endpoint, 'interval', seconds=15) # Call every 30 seconds
62
- # scheduler.start()
63
 
64
  @app.post("/get_image_for_text")
65
  async def get_image_for_text(email,query,file: UploadFile = File(...)):
 
6
  from io import StringIO
7
  import os
8
  import uuid
9
+ from apscheduler.schedulers.background import BackgroundScheduler
10
 
11
  # import googletrans
12
  # from googletrans import Translator
 
36
  from PIL import Image
37
  from io import BytesIO
38
 
39
+ # @app.post("/translator")
40
+ # async def tra(sentence,lang):
41
+ # lang = lang.lower()
42
+ # return translator.translate(sentence,dest=keys[vals.index(lang)]).text
43
 
44
  def convert_image_to_base64(image_path):
45
  with Image.open(image_path) as image:
 
52
 
53
 
54
  # # Function to call the endpoint
55
+ def call_my_endpoint():
56
  # #response = requests.get("http://127.0.0.1:8000/my-endpoint")
57
+ print(f"Endpoint response: {response.json()}")
58
 
59
  # # Configure the scheduler
60
+ scheduler = BackgroundScheduler()
61
+ scheduler.add_job(call_my_endpoint, 'interval', seconds=15) # Call every 30 seconds
62
+ scheduler.start()
63
 
64
  @app.post("/get_image_for_text")
65
  async def get_image_for_text(email,query,file: UploadFile = File(...)):