Skip to content

Commit 6dbcc1c

Browse files
committed
Add Flask app with single /datasets endpoint
1 parent 144ef73 commit 6dbcc1c

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__pycache__

Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: gunicorn app:app

app.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import random
2+
3+
from flask import Flask, jsonify
4+
from datasets import DownloadMode, load_dataset
5+
6+
app = Flask(__name__)
7+
8+
print('Downloading the dataset...')
9+
masader = load_dataset('arbml/masader')
10+
11+
12+
@app.route('/datasets')
13+
def datasets():
14+
global masader
15+
16+
if random.random() <= 0.1:
17+
print('Re-downloading the dataset...')
18+
masader = load_dataset('arbml/masader', download_mode=DownloadMode.FORCE_REDOWNLOAD)
19+
20+
return jsonify(list(masader['train']))

requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Flask==2.1.2
2+
datasets==2.3.2
3+
gunicorn==20.1.0

0 commit comments

Comments
 (0)