Skip to content

Commit

Permalink
gunicorn changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Anand Taralika committed Jun 21, 2023
1 parent 601e713 commit bae2c4e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
2 changes: 0 additions & 2 deletions finviz/main_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ def get_stock(ticker):
keys = ["Ticker", "Company", "Sector", "Industry", "Country"]
fields = [f.text_content() for f in title.cssselect('a[class="tab-link"]')]
data = dict(zip(keys, fields))
print(fields)
print(data)

company_link = title.cssselect('a[class="tab-link"]')[0].attrib["href"]
data["Website"] = company_link if company_link.startswith("http") else None
Expand Down
36 changes: 23 additions & 13 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from flask import escape,jsonify

from flask import Flask, jsonify, request
import finviz
import requests

app = Flask(__name__)

def quote(request):
@app.route("/quote")
def quote():
"""HTTP Cloud Function.
Args:
request (flask.Request): The request object.
Expand All @@ -12,14 +15,21 @@ def quote(request):
Response object using `make_response`
<https://flask.palletsprojects.com/en/1.1.x/api/#flask.make_response>.
"""
request_json = request.get_json(silent=True)
request_args = request.args

if request_json and 't' in request_json:
ticker = request_json['t']
elif request_args and 't' in request_args:
ticker = request_args['t']
else:
ticker = 'AMZN'
ticker = request.args.get('t')

if not ticker:
return jsonify({'error': 'Ticker not provided.'}), 400

# request_json = request.get_json(silent=True)
# request_args = request.args

return jsonify(finviz.get_stock(ticker))
# if request_json and 't' in request_json:
# ticker = request_json['t']
# elif request_args and 't' in request_args:
# ticker = request_args['t']
# else:
# ticker = 'AMZN'
try:
return jsonify(finviz.get_stock(ticker))
except requests.exceptions.HTTPError as err:
return jsonify({'error': str(err)}), err.response.status_code

1 comment on commit bae2c4e

@vercel
Copy link

@vercel vercel bot commented on bae2c4e Jun 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

finviz – ./

finviz.vercel.app
finviz-git-master-taralika.vercel.app
finviz-taralika.vercel.app

Please sign in to comment.