Skip to content

Commit

Permalink
πŸ‘©πŸΌβ€πŸŽ¨βš°οΈ ↝ Merge pull request #45 from Signal-K/GP-28-P
Browse files Browse the repository at this point in the history
πŸ’³πŸ‘©πŸΌβ€πŸŽ¨ ↝ Gp 28 p
  • Loading branch information
Gizmotronn authored Jun 1, 2024
2 parents a88ce81 + 8192a29 commit e150144
Show file tree
Hide file tree
Showing 130 changed files with 15,919 additions and 1,302 deletions.
Binary file modified .DS_Store
Binary file not shown.
36 changes: 36 additions & 0 deletions .github/workflows/flake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Flask App CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Test with pytest
run: pytest

- name: Lint with flake8
run: |
pip install flake8
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
- name: Run Flask app
run: python app.py
12 changes: 0 additions & 12 deletions .gitmodules

This file was deleted.

11 changes: 11 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This configuration file was automatically generated by Gitpod.
# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml)
# and commit this file to your remote git repository to share the goodness with others.

# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart

tasks:
- init: npm install && npm run build && make
command: npm run start


5 changes: 0 additions & 5 deletions Contracts/contractAddresses.ts

This file was deleted.

73 changes: 0 additions & 73 deletions Contracts/planetDrop.py

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ RUN pipenv install
COPY . .

# CMD ["python", "-m", "flask", "run", "--host=0.0.0.0"]
CMD ["pipenv", "run", "flask", "run", "--host=0.0.0.0"]
CMD ["pipenv", "run", "flask", "run", "--host=0.0.0.0"]
1 change: 1 addition & 0 deletions Exoplanet Finder.ipynb

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
[packages]
moralis = "*"
flask = "*"ac
flask_cors = "*"
thirdweb-sdk = "*"
python-dotenv = "*"
psycopg2 = "*"
matplotlib = "*"
lightkurve = "*"
nbformat = "*"
gunicorn = "*"
sqlalchemy = "*"
psycopg2-binary = "*"
flask-sqlalchemy = "*"
supabase = "*"
gotrue = "*"
noise = "*"
11 changes: 11 additions & 0 deletions Pipfile.extra
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
web3 = "*"
brownie = "*"
eth-brownie = "*"
eth_utils = "*"
thirdweb-sdk = "*"
moralis = "*"
psycopg2 = "*"
psycopg2-binary = "*"
flask-sqlalchemy = "*"
sqlalchemy = "*"
gotrue = "*"
Empty file added __init__.py
Empty file.
112 changes: 59 additions & 53 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,65 +1,71 @@
from flask import Flask, request, make_response, jsonify, Blueprint
from flask import Flask, jsonify, request, g
import requests

import base64
from io import BytesIO
app = Flask(__name__)

from database.store import planets, add_planet_to_DB
# from Generator import gen_image # add this to a blueprint
# Store authentication details in a global variable 'auth'
auth = None

from database.datastore import solObjects # get this from database.store / supabase-py in prod
@app.route("/")
def index():
return "Hello world"

import time
@app.route('/login', methods=['POST'])
def login():
global auth # Use the global 'auth' variable to store authentication details

app = Flask(__name__)

@app.route('/', methods=['GET', 'POST'])
def index():
return jsonify(solObjects)
# Parse the JSON request data
data = request.get_json()
username = data.get('username')
password = data.get('password')

@app.route('/planet', methods=['GET', 'POST'])
def index():
return jsonify(planets)
# Check if username and password are provided
if not username or not password:
return jsonify({'error': 'Username and password are required'}), 400

@app.route('/time')
def get_current_time():
return {'time': time.time()}
# Send a POST request to the NASA Earthdata login API
response = requests.post(
'https://appeears.earthdatacloud.nasa.gov/api/login',
auth=(username, password)
)

# Check if the request was successful
if response.status_code == 200:
token_response = response.json()
# Store authentication details in the 'auth' variable
auth = (username, password)
return jsonify(token_response)
else:
return jsonify({'error': 'Login failed'}), 401

# GET request -> return all planets in storage/db in JSON format
@app.route('/planets')
def get_planets():
return jsonify({
'planets': planets, # Then present this on react frontend, port 5000 -> 3000
})
@app.route('/get_geolocation', methods=['POST'])
def get_geolocation():
global auth # Use the global 'auth' variable for authentication

@app.route('/planets/<planet_id>')
def find_planet_by_id(planet_id):
for planet in planets:
if planet["id"] == int(planet_id):
return jsonify({
"planet": planet,
})
# Check if authentication details are available
if not auth:
return jsonify({'error': 'Authentication required'}), 401

@app.route('/planets/add', methods=['POST'])
def add_planet():
# Parse the JSON request data
data = request.get_json()
try:
title = data['title']
if title:
data = add_planet_to_DB(title)
return jsonify(data), 201
except:
return Response('''{"message": "Bad Request"}''', status=400, mimetype='application/json')
address = data.get('address')

# Check if address is provided
if not address:
return jsonify({'error': 'Address is required'}), 400

# Send a POST request to fetch geolocation using stored authentication
response = requests.get(
f'https://geocode.maps.co/search?q={address}',
auth=auth
)

# Check if the request was successful
if response.status_code == 200:
geoloc_data = response.json()
return jsonify(geoloc_data)
else:
return jsonify({'error': 'Geolocation fetch failed'}), 500

@app.route('/generator')
def generate():
# Generate the figure **without using pyplot**.
res = 2048 # see generate blueprint above
"""fig = Figure()
ax = fig.subplots()
ax.plot([1, 2])
# Save it to a temporary buffer.
buf = BytesIO()
fig.savefig(buf, format="png")
# Embed the result in the html output.
data = base64.b64encode(buf.getbuffer()).decode("ascii")
return f"<img src='data:image/png;base64,{data}'/>"""#"
if __name__ == "__main__":
app.run()
85 changes: 0 additions & 85 deletions auth/thirdwebHandler.py

This file was deleted.

Loading

0 comments on commit e150144

Please sign in to comment.