This is a project based on VS Code Remote - Containers
This will grab the top headlines from a news API and run them through the Google Natural Language API sentiment analyzer. You can use this information to decide if you want to get up in the morning, or stay in bed.
Requirements for developing in a remote container:
- Docker
- Microsoft Visual Studio Code with the Remote Containers extension installed.
- environment.env and gcloudkey.json files in the root folder.
- environment.env contents:
- GOOGLE_APPLICATION_CREDENTIALS=gcloudkey.json
- NEWSAPIKEY='apiKey from newsapi.org' (see https://newsapi.org/docs/get-started for info on how to get an API key)
- gcloudkey.json contents: A private key in JSON format for a Google cloud service account that has access to a project where the Google Natural Language API is enabled (see https://cloud.google.com/natural-language/docs/quickstart-client-libraries for info on setting up a project and service account)
- environment.env contents:
Example commands to run the server from a Python virtualenv (aka without VSCode's help):
- export FLASK_APP=app.py FLASK_ENV=development FLASK_DEBUG=0 GOOGLE_APPLICATION_CREDENTIALS=gcloudkey.json NEWSAPIKEY='apiKey from newsapi.org'
- flask run --host 0.0.0.0 --port 9000 &
Sample requests:
- Get and analyze the most recent headlines about everything: http://localhost:9000/news
- Get headlines about a specific subject: http://localhost:9000/news?subject=impeachment
- Get and analyze an insult from evilinsult.com: http://localhost:9000/insult