Skip to content

Commit 27d75ea

Browse files
committed
Add /highlights endpoint
1 parent ea64e84 commit 27d75ea

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
__pycache__
22
.idea/
33
.env
4-

README.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,23 @@ Make sure to apply `pre-commit` hooks before submitting any pull request by runn
167167
}
168168
```
169169

170+
### /highlights
171+
172+
- Method: `GET`
173+
- Description: Returns short string highlights the new changes in Masader.
174+
- Path Arguments: N/A
175+
- Parameters: N/A
176+
- Data: N/A
177+
- Return Type: `JSON`
178+
- Example Link: https://masader-web-service.herokuapp.com/highlights
179+
- Example Output:
180+
181+
```json
182+
{
183+
"highlights": "Masader is COOL!"
184+
}
185+
```
186+
170187
### /refresh/[password]
171188

172189
- Method: `GET`
@@ -180,5 +197,5 @@ Make sure to apply `pre-commit` hooks before submitting any pull request by runn
180197
- Example Output:
181198

182199
```json
183-
"The datasets updated successfully! The current number of available datasets is 590."
200+
"Datasets refresh process initiated successfully!"
184201
```

app.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import os
23

34
from multiprocessing import Process
45

@@ -7,10 +8,9 @@
78

89
from flask import Flask, jsonify, request
910
from flask_cors import CORS
11+
1012
from utils.common_utils import dict_filter
1113
from utils.dataset_utils import refresh_masader_and_tags
12-
13-
1414
from utils.gh_utils import create_issue
1515

1616

@@ -88,6 +88,11 @@ def create_dataset_issue(index: int):
8888
return jsonify({'issue_url': create_issue(f"{masader[index]['Name']}: {title}", body)})
8989

9090

91+
@app.route('/highlights')
92+
def get_highlights():
93+
return jsonify({'highlights': os.environ.get('HIGHLIGHTS', '')})
94+
95+
9196
@app.route('/refresh/<string:password>')
9297
def refresh(password: str):
9398
print('Refreshing globals...')
@@ -97,7 +102,7 @@ def refresh(password: str):
97102

98103
Process(name='refresh_globals', target=refresh_masader_and_tags, args=(db,)).start()
99104

100-
return jsonify('The datasets updated successfully!')
105+
return jsonify('Datasets refresh process initiated successfully!')
101106

102107

103108
with app.app_context():

constants.py

-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@
1111
SEVEN_DAYS_IN_SECONDS = 604800
1212

1313
MASADER_GH_REPO = 'ARBML/masader'
14-

0 commit comments

Comments
 (0)