https://github.com/hazems/aws-lambda-python-covid19-news
This is a sample AWS Python3 COVID-19 Headline News API.
https://github.com/hazems/aws-lambda-python-covid19-news
aws aws-lambda python3 rest
Last synced: 5 months ago
JSON representation
This is a sample AWS Python3 COVID-19 Headline News API.
- Host: GitHub
- URL: https://github.com/hazems/aws-lambda-python-covid19-news
- Owner: hazems
- Created: 2020-03-17T04:56:12.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-26T03:24:00.000Z (over 6 years ago)
- Last Synced: 2025-03-27T18:53:19.945Z (over 1 year ago)
- Topics: aws, aws-lambda, python3, rest
- Language: Python
- Size: 2.05 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# AWS Lambda COVID-19 Headline News API
This is a sample AWS Python3 COVID-19 Headline News API. The following diagram illustrates the design, as shown below, you can create an HTML file inside an S3 bucket, and in this HTML file, you can send an XHR request to the Lambda function and then you can render the news as you wish:

## How to run this sample?
To be able to run this sample, you need to get an API key from https://newsapi.org/
## Client Sample
You can use this code as a client sample that calls Lambda service.
```
$(document).ready(function() {
$.get("[Here Place your API Endpoint URL]", function(data) {
var content = "";
for (var i = 0; i < data.length; ++i) {
content += createCard(data[i].author, data[i].title, data[i].description, data[i].imageUrl, data[i].newsUrl);
}
$("#result").html(content);
});
});
function createCard(author, title, description, imageUrl, newsUrl) {
if (description == null) {
description = "To be provided soon";
}
return "<div class=\"card\">" +
"<div class=\"card-header\">" +
"By " + author +
"</div>" +
"<div class=\"card-body\">" +
"<h5 class=\"card-title\">" + title + "</h5>" +
"<p class=\"card-text\">" + description + "</p>" +
"<p><img src=\"" + imageUrl + "\" height='300px' width='500px' alt=\"...\"></p>" +
"<a target=\"_blank\" href=\"" + newsUrl + "\" class=\"btn btn-primary\">Go to News Source</a>" +
"</div>"+
"</div><br/>";
}
body {
padding: 10px;
}
h1 {
padding-bottom: 5px;
}
.jumbotron {
color: white;
background-image: url("covid19.jpg");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
COVID-19 Breakout!
Get the latest news about this virus from different News sources
```
## Output
The client output will be rendered as shown below.
