-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add an API test. * Try to enable GitHub Actions. * Try to remove the Werkzeug warning. * Get a real quote. * Rename package to src for now. While pyproject.toml must contain the package name, using a name other than "src" would require cascading changes to the submodules. Let's leave that for a later stage, if required. * Allow Python 3.10. * Allow Python ^3.8. Recent Flask requires ^3.8. * Skip checking for requirements.txt (extra step). * Remove requirements.txt. * Add PyTest as a plain dependency. * Specify Mark as the author. * Refactor: Move server logic from main.py to src/server.py. * Debug: Print current values. * Remove a debug print. * Remove CircleCI config. Configured GitHub Actions instead. If that isn't equivalent, we can revert. * Untrack .envrc. * Remove .envrc. * Add PyLint exclusions for most common warnings. These specific warnings were so numerous they obscured the code. Before anyone gets to cleaning these warnings [1], let's disable them for now just to make reading the code easier. [1]: *If* they should ever be cleaned at all. * Move test_api to tests/. * Remove unneeded mock.
- Loading branch information
Showing
31 changed files
with
869 additions
and
91 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# This workflow will install Python dependencies, and run tests with a single | ||
# version of Python. | ||
# | ||
# For more information see: | ||
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: IsThisStockGood | ||
|
||
on: | ||
push: | ||
branches: [ "*" ] | ||
pull_request: | ||
branches: [ "*" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.10" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pytest==8.2.1 | ||
pip install -e . | ||
- name: Test with pytest | ||
run: | | ||
pytest |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ env/ | |
|
||
# For Pycharm | ||
.idea | ||
.envrc |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,7 @@ | ||
import logging | ||
from datetime import date | ||
from flask import Flask, request, render_template | ||
from src.DataFetcher import fetchDataForTickerSymbol | ||
|
||
logger = logging.getLogger("IsThisStockGood") | ||
|
||
handler = logging.StreamHandler() | ||
handler.setLevel(logging.WARNING) | ||
|
||
h_format = logging.Formatter('%(name)s - %(levelname)s : %(message)s') | ||
handler.setFormatter(h_format) | ||
|
||
logger.addHandler(handler) | ||
|
||
app = Flask(__name__) | ||
|
||
|
||
@app.route('/') | ||
def homepage(): | ||
if request.environ['HTTP_HOST'].endswith('.appspot.com'): #Redirect the appspot url to the custom url | ||
return '<meta http-equiv="refresh" content="0; url=https://isthisstockgood.com" />' | ||
|
||
template_values = { | ||
'page_title' : "Is This Stock Good?", | ||
'current_year' : date.today().year, | ||
} | ||
return render_template('home.html', **template_values) | ||
|
||
|
||
@app.route('/search', methods=['POST']) | ||
def search(): | ||
if request.environ['HTTP_HOST'].endswith('.appspot.com'): #Redirect the appspot url to the custom url | ||
return '<meta http-equiv="refresh" content="0; url=http://isthisstockgood.com" />' | ||
|
||
ticker = request.values.get('ticker') | ||
template_values = fetchDataForTickerSymbol(ticker) | ||
if not template_values: | ||
return render_template('json/error.json', **{'error' : 'Invalid ticker symbol'}) | ||
return render_template('json/stock_data.json', **template_values) | ||
from src.server import create_app | ||
|
||
|
||
if __name__ == '__main__': | ||
app = create_app(fetchDataForTickerSymbol) | ||
app.run(host='127.0.0.1', port=8080, debug=True) |
Oops, something went wrong.