Skip to content

Instantly share code, notes, and snippets.

@muthugit
Created November 25, 2018 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muthugit/983fe60b7b1421e9dc91f86252e1b34c to your computer and use it in GitHub Desktop.
Save muthugit/983fe60b7b1421e9dc91f86252e1b34c to your computer and use it in GitHub Desktop.
import pandas as pd
from flask import request
from flask import Flask
from flask_cors import CORS, cross_origin
app = Flask(__name__)
cors = CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'
df = pd.read_csv("data.csv")
@app.route("/2d")
@cross_origin()
def twod():
x = request.args.get('x')
y = request.args.get('y')
requiredDf = df[[x,y]].copy()
requiredDf.columns=["dimensions","measure"]
json = requiredDf.to_json(orient='records')
return json
if __name__ == "__main__":
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment