An open API service indexing awesome lists of open source software.

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.

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:
![Architecture Diagram](figures/architecture.png)

## 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.
![Output](figures/output.png)