Giter Site home page Giter Site logo

nasa-mars-pics-api's Introduction

NASA Mars Pics API

Concept

NASA provides many publicly available APIs. One of them returns photos gathered by rovers sent to Mars. Unfortunately, many photos are relatively dull (you can read about it in this post). This program is supposed to gather the links to photos, check if they might contain interesting content, and then display a random photo when a URL is accessed.

Setup

Clone this repository, then create a .env file:

DATABASE_URL=postgresql://nasa:nasa@db:5432/nasa
NASA_API_KEY={YOUR_NASA_API_KEY}

You can apply for a NASA API key here. Without it, a DEMO_KEY value will be used, which does not provide adequate performance (you will not be allowed to access the API frequently enough to index the data).

You can build and run the project using docker-compose:

docker-compose build
docker-compose up

Usage

To index the data run:

docker exec -it nasa-mars-pics-api_web_1 python index_photos.py

This will run a loop that accesses NASA API, saves the image links in the database, and checks the attributes of images (size and color mode) to decide if they are worth displaying.

To get a random image, access http://localhost:8888. You will probably need to wait a moment before the first acceptable image becomes available, until then you will receive a 500 Internal Server Error.

Deploying to Heroku

You can easily run this on Heroku. You need to add Heroku Postgres add-on and provide the same 2 config vars as in the .env file

Demo

Demo is available here. Keep in mind that, since it's Heroku and the application falls asleep after a while , it can take a while for the first image to be shown.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.