Skip to content

Commit c39f8f3

Browse files
committed
added a pandas dataframe to a basic flask endpoint
1 parent 3038592 commit c39f8f3

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

Scripts/env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export FLASK_APP=app.py
22
export FLASK_ENV=development
3-
flask run
43
echo "Flask is running in ${FLASK_ENV} mode."
4+
flask run

app.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1+
import pandas as pd
12
from flask import Flask
23

34
app = Flask(__name__)
45

56
@app.route('/')
6-
def hello_world():
7-
return 'Hello, World!'
7+
def index():
8+
sample_dict = {
9+
"Name": [
10+
"Braund, Mr. Owen Harris",
11+
"Allen, Mr. William Henry",
12+
"Bonnell, Miss. Elizabeth",
13+
],
14+
"Age": [22, 35, 58],
15+
"Sex": ["male", "male", "female"],
16+
}
17+
18+
df = pd.DataFrame(sample_dict)
19+
print(df)
20+
return df.to_json()

0 commit comments

Comments
 (0)