Giter Site home page Giter Site logo

d-bhatta / nasa-get Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 3.91 MB

A DJango app that displays results from querying NASA's public APIs

Home Page: https://d5625.pythonanywhere.com/home/

License: GNU General Public License v3.0

Python 2.05% HTML 94.85% CSS 3.10%

nasa-get's Introduction

Nasa-Get

A Django app that displays results from querying NASA's public APIs.

Table of Contents

How to use

  • Click on the app link
  • Get a new API key from NASA and enter it there
  • Click on any of the APIs available

The results along with useful information about the API will be displayed.

Project Status

Project is currently under active development.

Additional Information

Screenshots

Main App screen

Homepage

API index screen

API index screen

API results screen

API results screen

Links

Notes

  • I created a layered architecture of python classes to query NASA's Open APIs and extract useful information from it
  • I fine-tuned architecture design such that only 2 functions and a database entry need to be to add a new API to the app
  • I developed a view to accept user API key and securely store them in a database
  • I created a page to display API information automatically in a responsive card view

nasa-get's People

Contributors

d-bhatta avatar dependabot[bot] avatar

Stargazers

Kevonne Cinque Montes avatar

Watchers

 avatar

nasa-get's Issues

Secret keys are written every time the server starts

Secret keys are written every time the server starts

Whenever the server runs, it checks for secret keys in the environment variables. Since there aren't any, it appends a new secret key to the .env file. The file is cluttered now, and will grow infinitely larger later.

To Reproduce
Steps to reproduce the behavior:

  1. Run the server
  2. New secret key is created in .envfile.

Expected behavior
The server should load environment variables as soon as it starts. It shouldn't write new keys everytime it starts.

Screenshots
If applicable, add screenshots to help explain your problem.

An overview of the suggested solution

Describe the solution you'd like

Add code to setup environment variables to the top of the file, right below import statements in settings.py.

Files

  • settings.py

Prevent use of DEMO_KEY

Prevent use of DEMO_KEY

Is your feature request related to a problem? Please describe.
Prevent use of DEMO_KEY

An overview of the suggested solution

Describe the solution you'd like
Catch if the API key is DEMO_KEY and show an error page.

Has the feature been requested before?

No

If the feature request is approved, would there be a need for further development in this area?
Yes, if DEMO_KEY changes.

Get the results of API preemptively to save time

Get the results of API preemptively to save time

Is your feature request related to a problem? Please describe.
Get the results of all APIs preemptively when someone clicks on API index

When someone clicks on the API index, get the API results and store them. This will save time.

This should be done in an encapsulated manner, so that there can be further development in this area.

If the feature request is approved, would there be a need for further development in this area?
Yes

This preemptive storage of data could be optimised further

Token and encryption expiry

Token and encryption expiry

Is your feature request related to a problem? Please describe.
Tokens and encrypted keys expire after a while.

An overview of the suggested solution

Describe the solution you'd like
Tokens and encrypted stuff should expire after a while. This means all tokens will be automatically recycled.

API Index page

API Index page

  • Cards are displayed that show all the APIs that a user can access
  • Each card has a picture, a heading corresponding to the API name, and a link to selected API page
  • The app should show stuff in cards
  • Each card should have a picture, a heading, and a link to a page
  • The app should take the data to populate the cards from a data base
  • Each card will open onto a new page with a particular id

An overview of the suggested solution

Describe the solution you'd like

  • Create models to store info about APIs
  • Create view that renders each api in database as a card.
  • Register urls for the choose api view
  • Create a template page to render apis as cards

Add other APIs

Add other APIs

Is your feature request related to a problem? Please describe.
Add other APIs from Nasa

Non-persistence of data

Non-persistence of data

Is your feature request related to a problem? Please describe.
Remove all API keys from memory on start to prevent misuse. I don't want to hold onto the data.

An overview of the suggested solution

Describe the solution you'd like
When the App initializes, delete all keys stored in the database

Authenticate using a token

Authenticate using a token

Is your feature request related to a problem? Please describe.
Send a token and authenticate using it.

An overview of the suggested solution

Describe the solution you'd like
After the user sends in an API key, return a token and save it in local storage. Use it to authenticate user.

Result of the selected API page

Result of the selected API page

  • If no API key, redirect to home page
  • Display the result of the particular API
  • Take 3 API from NASA to test
  • Compute the API result
  • Return the API result
  • Display the result

An overview of the suggested solution

Describe the solution you'd like

  • Create results view: render api_result.html page with selected api result as context
  • Create urls with path as <int:id>/
  • Create api_result.html template

Add basic app features

Add basic app features

Is your feature request related to a problem? Please describe.
Add the following app features

  1. Show a homepage that explains the app
  2. Take API key from user
  3. Show a page where they can select what API they want to use it for: Choose your API page
  4. Show the result of the selected API

An overview of the suggested solution

Describe the solution you'd like

Homepage

  • Show a homepage with text about the form
  • Display a form input for users to enter their API key
  • Store API key for user after encrypting it
  • Redirect to API Index page

API Index page

  • Cards are displayed that show all the APIs that a user can access
  • Each card has a picture, a heading corresponding to the API name, and a link to selected API page
  • The app should show stuff in cards
  • Each card should have a picture, a heading, and a link to a page
  • The app should take the data to populate the cards from a data base
  • Each card will open onto a new page with a particular id

Result of the selected API page

  • If no API key, redirect to home page
  • Display the result of the particular API
  • Take 3 API from NASA to test
  • Compute the API result
  • Return the API result
  • Display the result

Show a proper error page on API errors

Show a proper error page on API errors

Is your feature request related to a problem? Please describe.
Show a proper error page on API errors

An overview of the suggested solution

Describe the solution you'd like
Create error pages for API key errors, and other errors.

Has the feature been requested before?

No
If the feature request is approved, would there be a need for further development in this area?
Yes.

Add a Homepage

Add a Homepage

  • Show a homepage with text about the form
  • Display a form input for users to enter their API key
  • Store API key for user
  • Redirect to API Index page

An overview of the suggested solution

Describe the solution you'd like

  • Modify base.html to make it mission ready
  • Create a short instruction paragraph below the heading
  • Create a form with an input field and a button
  • Create a model to store user API
  • Create a view that is used to save form data and model and redirect to API Index page
  • Redirect to API Index page
  • Refactor as needed

Add Logging to app

Add Logging to app

Is your feature request related to a problem? Please describe.
There isn't a logging feature in the app, which makes debugging terrible.

An overview of the suggested solution

Add a logging feature.

Files

A config file is already there for the taking.

Tasks

Include specific tasks in the order they need to be done in. Include links to specific lines of code where the task should happen at.

  • Add logging to views.py of the homepage app.

Remember to use helpful labels and milestones.

Has the feature been requested before?

No

If the feature request is approved, would there be a need for further development in this area?
Yes

Refactor `Nasa` class to add inheritance

Refactor Nasa class to add inheritance

Is your feature request related to a problem? Please describe.
Create a base class Provider that Nasa class can inherit from.

Refactor the settings.py file to enable getting host names from .env

Refactor the settings.py file to enable getting host names from .env

Is your feature request related to a problem? Please describe.
Currently the hostname for PythonAnywhere is hard coded. It should be placed into the .env file, and retrieved as an environment variable.

An overview of the suggested solution

Describe the solution you'd like
Move the host name to the .env file and retrieve it from there during initialization.

If the feature changes current behavior, reasons why your solution is better

The host name is nolonger hardcoded, and the app can now be run anywhere.

Alternative Solutions

Describe alternatives you've considered

  • Retrieving it from another settings file
  • Leaving it hardcoded and changing it only when needed.

Files

  • settings.py

Tasks

Include specific tasks in the order they need to be done in. Include links to specific lines of code where the task should happen at.

  • Move the hostname string into the .env file.
  • Change the settings.py code to retrieve the hostname from the environment
    • Make sure to catch KeyError on not finding a key, and get it from the .env file
  • Deploy app to see if it works.

Has the feature been requested before?

No

If the feature request is approved, would there be a need for further development in this area?
Yes, this should not require further work.

Refactor classes to make them singleton

Refactor classes to make them singleton

Is your feature request related to a problem? Please describe.
Classes in apis.py module and ContextBuilder can be made into static singletons, which can be made once and then used again and again. This will probably reduce the overhead of using the app.

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.