lalithadevi
commited on
Commit
•
eec495e
1
Parent(s):
b9f7696
Update app.py
Browse files
app.py
CHANGED
@@ -13,15 +13,17 @@ logging.warning('Initiated')
|
|
13 |
@app.route("/")
|
14 |
@cross_origin()
|
15 |
def update_news():
|
16 |
-
|
|
|
17 |
try:
|
18 |
db = DBOperations()
|
19 |
news_df = get_news()
|
20 |
news_json = [*json.loads(news_df.reset_index(drop=True).to_json(orient="index")).values()]
|
21 |
db.insert_news_into_db(news_json)
|
22 |
except:
|
23 |
-
|
24 |
-
|
|
|
25 |
|
26 |
|
27 |
if __name__ == "__main__":
|
|
|
13 |
@app.route("/")
|
14 |
@cross_origin()
|
15 |
def update_news():
|
16 |
+
status_json = "{'status':'success'}"
|
17 |
+
status_code = 200
|
18 |
try:
|
19 |
db = DBOperations()
|
20 |
news_df = get_news()
|
21 |
news_json = [*json.loads(news_df.reset_index(drop=True).to_json(orient="index")).values()]
|
22 |
db.insert_news_into_db(news_json)
|
23 |
except:
|
24 |
+
status_json = "{'status':'failure'}"
|
25 |
+
status_code = 500
|
26 |
+
return Response(status_json, status=status_code, mimetype='application/json')
|
27 |
|
28 |
|
29 |
if __name__ == "__main__":
|