Skip to content

Commit

Permalink
Merge pull request #39 from hack4impact-calpoly/oli/merge
Browse files Browse the repository at this point in the history
Oli/merge
  • Loading branch information
oli-lane authored Feb 13, 2024
2 parents 2e72232 + 26c7ca9 commit becae35
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"app_name": "api",
"stages": {
"dev": {
"api_gateway_stage": "src"
"api_gateway_stage": "api"
}
}
}
File renamed without changes.
18 changes: 11 additions & 7 deletions backend/api/src/app.py → backend/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,28 @@
def index():
return {"hello": "world"}


# The view function above will return {"hello": "world"}
# whenever you make an HTTP GET request to '/'.


# dummy endpoint retuns the data of the first user doc in users collection
@app.route("/test")
def test_endpoint():
db = client["test"]
collection = db["users"]
doc = collection.find_one()

if(doc is not None):
if doc is not None:
return {
"id":str(doc["_id"]),
"email":doc["email"],
"password":doc["password"]
"id": str(doc["_id"]),
"email": doc["email"],
"password": doc["password"],
}



# dummy post method
@app.route('/users', methods=['POST'])
@app.route("/users", methods=["POST"])
def create_user():
try:
# This is the JSON body the user sent in their POST request.
Expand All @@ -47,10 +50,11 @@ def create_user():
except Exception as e:
print(f"Failed to post: {e}")


# Here are a few more examples:
#
# @app.route('/hello/{name}')
# def hello_name(name):
# # '/hello/james' -> {"hello": "james"}
# return {'hello': name}
#
#
13 changes: 7 additions & 6 deletions backend/api/mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
import os
import certifi


def get_mongo_client():
load_dotenv('../../.env.local') #allows access of env variables from .env
URI = os.getenv('MONGO_URI')
load_dotenv("../../.env.local") # allows access of env variables from .env
URI = os.getenv("MONGO_URI")

try:
client = MongoClient(URI, tlsCAFile=certifi.where())
client.admin.command('ping') # confirm connection to db
client.admin.command("ping") # confirm connection to db
except Exception as e:
print(f"Error connecting to MongoDB: {e}")
client = None
print(f"Error connecting to MongoDB: {e}")
client = None

return client
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

slo_county_blueprint = Blueprint(__name__)

@slo_county_blueprint.route('/msg')

@slo_county_blueprint.route("/msg")
def hello_world():
return {'message': 'Hello World!'}
return {"message": "Hello World!"}
76 changes: 31 additions & 45 deletions backend/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit becae35

Please sign in to comment.