chabane commited on
Commit
5631eda
·
1 Parent(s): 787c3a2

add favicon and change in main file

Browse files
main.py CHANGED
@@ -118,6 +118,7 @@ def summerzation(file:UploadFile=File(...)):
118
 
119
  if len(file_bytes) > MAX_SIZE :
120
  return JSONResponse(content={"error": "too large file "},status_code=400)
 
121
  if extension == "pdf":
122
  text = get_text_from_PDF(file_bytes)
123
  elif extension == "docx":
@@ -145,21 +146,18 @@ def summerzation(file:UploadFile=File(...)):
145
 
146
 
147
  @app.post("/plot")
148
- def plot(user_need:str,file:UploadFile=File(...)):
149
  try:
150
  extension = file.filename.split(".")[-1]
151
  Supported_extensions = ["xlsx","xls"]
152
  if extension not in Supported_extensions:
153
  return JSONResponse(content={"error": "Unsupported file type"},status_code=400)
154
- file_bytes = file.read()
155
 
156
- try:
157
 
158
- if len(file_bytes) > MAX_SIZE :
159
- return JSONResponse(content={"error": "too large file "},status_code=400)
160
- except Exception as expEx:
161
- print(expEx)
162
- return JSONResponse(content={"error": "error in len "+str(expEx)},status_code=400)
163
 
164
  df = pd.read_excel(io=io.BytesIO(file_bytes))
165
  print(df.head())
@@ -194,7 +192,7 @@ error.
194
  match = re.search(r'```python(.*?)```', output[0]["generated_text"], re.DOTALL)
195
  code =''
196
  if not match:
197
- return JSONResponse(content={"error": "Can't generate the plot"},status_code=403)
198
 
199
  code = match.group(1).replace("plt.show()\n","")
200
 
@@ -214,10 +212,10 @@ error.
214
  return JSONResponse(content={"plot": f"data:image/png;base64,{base64_image}",'code':code},status_code=200)
215
  except Exception as e:
216
  print(e)
217
- return JSONResponse(content={"error": str(e) },status_code=500)
218
  except Exception as exp:
219
  print(exp)
220
- return JSONResponse(content={"error":"Internel Server Error:"+str(exp)} ,status_code=500)
221
 
222
 
223
 
@@ -248,7 +246,7 @@ def get_text_from_DOC(file_content):
248
  text += paragraph.text
249
  return text
250
 
251
- def get_text_from_EXCEL(file):
252
- df = pd.read_excel(io=io.BytesIO(file))
253
  text = df.to_string()
254
  return text
 
118
 
119
  if len(file_bytes) > MAX_SIZE :
120
  return JSONResponse(content={"error": "too large file "},status_code=400)
121
+ file.size()
122
  if extension == "pdf":
123
  text = get_text_from_PDF(file_bytes)
124
  elif extension == "docx":
 
146
 
147
 
148
  @app.post("/plot")
149
+ async def plot(user_need:str,file:UploadFile=File(...)):
150
  try:
151
  extension = file.filename.split(".")[-1]
152
  Supported_extensions = ["xlsx","xls"]
153
  if extension not in Supported_extensions:
154
  return JSONResponse(content={"error": "Unsupported file type"},status_code=400)
155
+ file_bytes = file.file.read()
156
 
 
157
 
158
+ if len(file_bytes) > MAX_SIZE :
159
+ return JSONResponse(content={"error": "too large file "},status_code=400)
160
+
 
 
161
 
162
  df = pd.read_excel(io=io.BytesIO(file_bytes))
163
  print(df.head())
 
192
  match = re.search(r'```python(.*?)```', output[0]["generated_text"], re.DOTALL)
193
  code =''
194
  if not match:
195
+ return JSONResponse(content={"error": "No Code was Generated"},status_code=403)
196
 
197
  code = match.group(1).replace("plt.show()\n","")
198
 
 
212
  return JSONResponse(content={"plot": f"data:image/png;base64,{base64_image}",'code':code},status_code=200)
213
  except Exception as e:
214
  print(e)
215
+ return JSONResponse(content={"error":"Can't execute the code : "+ str(e) },status_code=400)
216
  except Exception as exp:
217
  print(exp)
218
+ return JSONResponse(content={"error":"Internel Server Error: "+str(exp)} ,status_code=500)
219
 
220
 
221
 
 
246
  text += paragraph.text
247
  return text
248
 
249
+ def get_text_from_EXCEL(file_content):
250
+ df = pd.read_excel(io=io.BytesIO(file_content))
251
  text = df.to_string()
252
  return text
static/assets/favicon.ico ADDED
templates/data-visualization.html CHANGED
@@ -7,7 +7,7 @@
7
  <title>Data Visualization - SmartDoc AI</title>
8
  <link rel="preconnect" href="https://fonts.googleapis.com">
9
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
-
11
  <link rel="stylesheet" href="static/styles/notification.css">
12
  <link rel="stylesheet" href="static/styles/functions.css">
13
 
 
7
  <title>Data Visualization - SmartDoc AI</title>
8
  <link rel="preconnect" href="https://fonts.googleapis.com">
9
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
+ <link rel="shortcut icon" href="static/assets/favicon.ico" type="image/x-icon">
11
  <link rel="stylesheet" href="static/styles/notification.css">
12
  <link rel="stylesheet" href="static/styles/functions.css">
13
 
templates/image-interpretation.html CHANGED
@@ -7,7 +7,7 @@
7
  <title>Image Interpretation - SmartDoc AI</title>
8
  <link rel="preconnect" href="https://fonts.googleapis.com">
9
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
-
11
  <link rel="stylesheet" href="static/styles/notification.css">
12
  <link rel="stylesheet" href="static/styles/functions.css">
13
 
 
7
  <title>Image Interpretation - SmartDoc AI</title>
8
  <link rel="preconnect" href="https://fonts.googleapis.com">
9
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
+ <link rel="shortcut icon" href="static/assets/favicon.ico" type="image/x-icon">
11
  <link rel="stylesheet" href="static/styles/notification.css">
12
  <link rel="stylesheet" href="static/styles/functions.css">
13
 
templates/index.html CHANGED
@@ -5,10 +5,11 @@
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
  <title>SmartDoc AI - Intelligent Document Processing</title>
8
- <link rel="stylesheet" href="static/styles/index.css">
9
  <link rel="preconnect" href="https://fonts.googleapis.com">
10
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
11
- <!-- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">-->
 
 
12
  </head>
13
 
14
  <body>
 
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
  <title>SmartDoc AI - Intelligent Document Processing</title>
 
8
  <link rel="preconnect" href="https://fonts.googleapis.com">
9
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
+ <link rel="shortcut icon" href="static/assets/favicon.ico" type="image/x-icon">
11
+ <link rel="stylesheet" href="static/styles/index.css">
12
+
13
  </head>
14
 
15
  <body>
templates/text-summarization.html CHANGED
@@ -7,7 +7,7 @@
7
  <title>Text Summarization - SmartDoc AI</title>
8
  <link rel="preconnect" href="https://fonts.googleapis.com">
9
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
-
11
  <link rel="stylesheet" href="static/styles/notification.css">
12
  <link rel="stylesheet" href="static/styles/functions.css">
13
 
 
7
  <title>Text Summarization - SmartDoc AI</title>
8
  <link rel="preconnect" href="https://fonts.googleapis.com">
9
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
+ <link rel="shortcut icon" href="static/assets/favicon.ico" type="image/x-icon">
11
  <link rel="stylesheet" href="static/styles/notification.css">
12
  <link rel="stylesheet" href="static/styles/functions.css">
13