Last active
February 15, 2019 12:31
-
-
Save Adarshreddyash/8140a712f06759c9e010e1ae72b64738 to your computer and use it in GitHub Desktop.
A gist that is a part of Api with python tutorial in Gspace | Adarshreddy adelli
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask,jsonify,request | |
import json | |
import requests | |
app=Flask(__name__) | |
@app.route('/') | |
def ash(req): | |
mandi=requests.get('https://api.data.gov.in/resource/9ef84268-d588-465a-a308-a864a43d0070?api-key=579b464db66ec23bdd000001cdd3946e44ce4aad7209ff7b23ac571b&format=json&offset=0&limit=1') | |
mandi=json.loads(mandi) | |
for item in mandi['records']: | |
response = """ | |
state: {0} | |
district: {1} | |
market: {2} | |
crop: {3} | |
variety: {4} | |
arrival date: {5} | |
min price: {6} | |
max price: {7} | |
modal price: {8} | |
""".format(item['state'],item['district'], item['market'] ,item['commodity'] ,item['variety'], item['arrival_date'] ,item['min_pric | |
return jsonify({'This is the output:':response}) | |
if __name__ =='__main__': | |
port = int(os.getenv('PORT',5000)) | |
print("starting gspace server on port %d" % port) | |
app.run(debug=True, port=port, host='0.0.0.0') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment