-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
54 lines (40 loc) · 1.55 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Import necessary modules
from flask import Flask, jsonify, render_template
import pandas as pd
# Create a Flask application
app = Flask(__name__)
# Define a route for the home page
@app.route("/")
def index():
# Render the "index.html" template
return render_template("index.html")
# Define a route for the iPhone Samsung details API
@app.route("/api/iphone_samsung_details")
def api_iphone_samsung_details():
# Read the iPhone Samsung merged data from CSV into a DataFrame
df= pd.read_csv('Cleaned Data\iphone_samsung_merged_data.csv')
df1=df.to_json(orient='records')
df1=pd.read_json(df1)
# Return the iPhone Samsung details as JSON
return jsonify(df1.to_dict(orient='records'))
# Define a route for the iPhone details API
@app.route("/api/iphone_details")
def api_iphone_details():
# Read the iPhone cleaned data from CSV into a DataFrame
df= pd.read_csv('Cleaned Data\iphone_cleaned_data.csv')
df1=df.to_json(orient='records')
df1=pd.read_json(df1)
# Return the iPhone details as JSON
return jsonify(df1.to_dict(orient='records'))
# Define a route for the Samsung details API
@app.route("/api/samsung_details")
def api_samsung_details():
# Read the Samsung cleaned data from CSV into a DataFrame
df = pd.read_csv('Cleaned Data\samsung_cleaned_data.csv')
df1=df.to_json(orient='records')
df1=pd.read_json(df1)
# Return the iPhone details as JSON
return jsonify(df1.to_dict(orient='records'))
# Run the application if this script is executed
if __name__ == "__main__":
app.run()