Skip to content

Commit

Permalink
test out the new API
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdisungkar committed May 31, 2024
1 parent 5100f39 commit 11773ef
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 26 deletions.
62 changes: 41 additions & 21 deletions application/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 1 addition & 1 deletion application/app/frontend/src/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
11 changes: 8 additions & 3 deletions application/app/frontend/src/pages/TripInformationPage.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion application/app/views/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 11773ef

Please sign in to comment.