Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
270 views
in Technique[技术] by (71.8m points)

My flask app is fetching data from third party API , while deploying this app on EC2 , its getting hanged

app.py is running fine , on ubuntu EC2 virtual machine .

Screenshot

But , when I run it with EC2 DCN , its keep on loading , doesn't show any output.

flask import jsonify, Flask
import requests
import json
import pandas as pd
from flask import Flask, render_template

app = Flask(__name__,template_folder='template')

@app.route('/')
def index():
    page = requests.get('https://www.nseindia.com/api/option-chain-indices?symbol=NIFTY' , headers = {'User-Agent': 'Mozilla/5.0'})
    page=json.loads(page.text)
    ce_values = [data['CE'] for data in page['records']['data'] if "CE" in data and data['expiryDate'] == "11-Feb-2021"]
    ce_dt = pd.DataFrame(ce_values).sort_values(['strikePrice'])
    return render_template('simple_VPS.html',  tables=[ce_dt.to_html(classes='data', header="true")])

Any solutions ?

question from:https://stackoverflow.com/questions/65952524/my-flask-app-is-fetching-data-from-third-party-api-while-deploying-this-app-on

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

nseindia is blocking requests originating from AWS and other main cloud providers. It is an issue know for a few years now.

You can check with nseindia if they offer some subscription plans which would allow you to whitelist your IPs from AWS. Otherwise, don't use AWS to access them.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...