Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trips #9

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added backend/__pycache__/app.cpython-311.pyc
Binary file not shown.
Binary file added backend/__pycache__/db.cpython-311.pyc
Binary file not shown.
Binary file added backend/__pycache__/init.cpython-311.pyc
Binary file not shown.
2 changes: 2 additions & 0 deletions backend/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ def create_app():

with app.app_context():
from routes.profile_routes import profile
from routes.trip_routes import trip
app.register_blueprint(profile)
app.register_blueprint(trip)
return app
Binary file not shown.
Binary file not shown.
8 changes: 7 additions & 1 deletion backend/routes/profile_routes.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
from flask import Flask, Blueprint, request
import json
from bson import json_util, ObjectId
from db import db
from db import db
import random

profile = Blueprint("profile", __name__, url_prefix="/profile")

@profile.route("/")
def profile_home():
return "This is the profile routes"

@profile.route("/getRandomUsername", methods = ['GET'])
def get_random_username():
data = db.profile.find({}, {"username" : True})
return json.loads(json_util.dumps(random.choice(list(data))))

@profile.route("/get/<string:username>", methods=['GET'])
def get_profile(username):

Expand Down
14 changes: 13 additions & 1 deletion backend/routes/trip_routes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
from flask import Flask, Blueprint, request
import json
from bson import json_util
from db import db

trip = Blueprint("trip", __name__, url_prefix="/trip")
trips = db.trip

@trip.route("/")
def trip_home():
return "This is the homepage for trips"
return "This is the profile routes"

@trip.route("/get/<string:state>", methods=['GET'])
def get_trip(state):
data = db.trip.find_one({'state': state})
return json.loads(json_util.dumps(data))