From 11773ef82b0d971aab561d0fb8e3e35eb2a8f6a1 Mon Sep 17 00:00:00 2001 From: ferdisungkar <60338815+ferdisungkar@users.noreply.github.com> Date: Fri, 31 May 2024 03:00:50 +0000 Subject: [PATCH] test out the new API --- application/Dockerfile | 62 ++++++++++++------- application/app/frontend/src/api/api.js | 2 +- .../frontend/src/pages/TripInformationPage.js | 11 +++- application/app/views/routes.py | 2 +- 4 files changed, 51 insertions(+), 26 deletions(-) diff --git a/application/Dockerfile b/application/Dockerfile index d13f03fc..b82698c3 100644 --- a/application/Dockerfile +++ b/application/Dockerfile @@ -1,34 +1,54 @@ +# FROM pypy:3.9-slim + +# # Installing dependencies for running the application +# RUN apt-get update && apt-get install -y libpq-dev postgresql-common gcc libgeos++-dev libgeos-3.9.0 libgeos-c1v5 libgeos-dev libgeos-doc +# RUN apt-get install -y openssl libcurl4-nss-dev libssl-dev curl + +# # Install NVM to manage installing npm 20 and Yarn +# ENV NVM_DIR "$HOME/.nvm" +# RUN mkdir -p ${NVM_DIR} +# RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash +# RUN /bin/bash -c "source ~/.bashrc && nvm install 20 && npm install --global yarn" + +# # Setting the working directory +# WORKDIR /app + +# # Install pipenv dependencies (Uses some separate precompiled wheels to avoid compiling) +# RUN pypy3 -m pip install --prefer-binary --extra-index-url https://pypy.kmtea.eu/simple pycurl==7.43.0 numpy +# COPY requirements.txt ./ +# RUN pypy3 -m pip install -r requirements.txt + +# # Copy our AWS credentials and construct an entrypoint script to source them +# COPY credentials ./ +# RUN printf '#!/bin/sh\n. ./credentials\nexec "$@"' > entrypoint.sh +# RUN chmod +x entrypoint.sh + +# # Copying our application into the container +# COPY app /app + +# # Build the frontend with yarn +# RUN /bin/bash -c "source ~/.bashrc && cd frontend && yarn install && yarn build" + +# # Running our application + entrypoint script +# ENTRYPOINT ["./entrypoint.sh"] +# CMD ["gunicorn", "--config", "gunicorn_config.py", "wsgi:app", "--preload"] + FROM pypy:3.9-slim -# Installing dependencies for running the application +# Installing dependencies for running a python application RUN apt-get update && apt-get install -y libpq-dev postgresql-common gcc libgeos++-dev libgeos-3.9.0 libgeos-c1v5 libgeos-dev libgeos-doc -RUN apt-get install -y openssl libcurl4-nss-dev libssl-dev curl - -# Install NVM to manage installing npm 20 and Yarn -ENV NVM_DIR "$HOME/.nvm" -RUN mkdir -p ${NVM_DIR} -RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash -RUN /bin/bash -c "source ~/.bashrc && nvm install 20 && npm install --global yarn" # Setting the working directory WORKDIR /app -# Install pipenv dependencies (Uses some separate precompiled wheels to avoid compiling) -RUN pypy3 -m pip install --prefer-binary --extra-index-url https://pypy.kmtea.eu/simple pycurl==7.43.0 numpy -COPY requirements.txt ./ -RUN pypy3 -m pip install -r requirements.txt +RUN pypy3 -m pip install --extra-index-url https://antocuni.github.io/pypy-wheels/manylinux2010 numpy -# Copy our AWS credentials and construct an entrypoint script to source them -COPY credentials ./ -RUN printf '#!/bin/sh\n. ./credentials\nexec "$@"' > entrypoint.sh -RUN chmod +x entrypoint.sh +# Install pipenv dependencies +COPY requirements.txt ./ +RUN pip install -r requirements.txt # Copying our application into the container COPY app /app -# Build the frontend with yarn -RUN /bin/bash -c "source ~/.bashrc && cd frontend && yarn install && yarn build" - -# Running our application + entrypoint script -ENTRYPOINT ["./entrypoint.sh"] +# Running our application CMD ["gunicorn", "--config", "gunicorn_config.py", "wsgi:app", "--preload"] \ No newline at end of file diff --git a/application/app/frontend/src/api/api.js b/application/app/frontend/src/api/api.js index 9680e87a..ec9bc189 100644 --- a/application/app/frontend/src/api/api.js +++ b/application/app/frontend/src/api/api.js @@ -22,7 +22,7 @@ export const getNearbyTripRequests = async (tripId, username, password) => { 'Content-Type': 'application/json', 'Accept': 'application/json', }, - body: JSON.stringify({ trip_id: tripId, username, password }) + body: JSON.stringify({ trip_id: tripId, username: username, password: password }) }); if (response.ok) { return response.json(); diff --git a/application/app/frontend/src/pages/TripInformationPage.js b/application/app/frontend/src/pages/TripInformationPage.js index 5cbf94a1..4a45f587 100644 --- a/application/app/frontend/src/pages/TripInformationPage.js +++ b/application/app/frontend/src/pages/TripInformationPage.js @@ -1,10 +1,11 @@ import React, { useContext, useEffect, useState } from 'react'; +import { useParams } from 'react-router-dom'; +import { useNavigate } from 'react-router-dom'; +import { UserContext } from '../components/UserContext'; import DriverInformationCard from '../components/DriverInformationCard'; import '../styles/TripInformationPage.css' -import { useParams } from 'react-router-dom'; import styles from '../styles/TripRequest.module.css'; -import { useNavigate } from 'react-router-dom'; -import { UserContext } from './UserContext'; + const TripInformation = () => { const { tripId } = useParams(); @@ -55,6 +56,10 @@ const TripInformation = () => { user_type: "driver" }), }); + console.log('username', user.username); + console.log('password', user.password); + console.log('target_user', driverUsername); + console.log('user_type driver'); if (response.ok) { const data = await response.json(); setDriverInformaion(data.user_info); diff --git a/application/app/views/routes.py b/application/app/views/routes.py index dc724e5c..9c581129 100644 --- a/application/app/views/routes.py +++ b/application/app/views/routes.py @@ -164,7 +164,7 @@ def post(self): contents = get_user_details_by_username_parser.parse_args() - user = get_user_from_username(contents.get("username")) + user = get_user_from_username(contents.get("target_username")) if user == None: return make_response({"error": "That user does not exist"}, 301)