Skip to content

Commit

Permalink
Update UPLOAD_PHOTO_FOR_DETECTION_ROUTE api route
Browse files Browse the repository at this point in the history
  • Loading branch information
thomashbrnrd committed Mar 7, 2024
1 parent a1b2068 commit 272c59a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 28 deletions.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- CACERT_LOCATION
context: ./backend
target: ${BUILD_TARGET:-dev}
command: uvicorn src.main:app --reload --host 0.0.0.0 --port 5000 --no-server-header
command: uvicorn src.main:app --reload --host 0.0.0.0 --port 8000 --no-server-header
container_name: basegun-backend
environment:
- S3_URL_ENDPOINT=http://minio:9000
Expand All @@ -23,7 +23,7 @@ services:
- WORKSPACE=dev
- REQUESTS_CA_BUNDLE=$CACERT_LOCATION
ports:
- 5000:5000
- 8000:8000
volumes:
- $PWD/backend/src:/app/src
- $PWD/backend/tests:/app/tests
Expand Down
2 changes: 1 addition & 1 deletion frontend/.env.development
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VITE_API_HOST=http://localhost:5000
VITE_API_HOST=http://localhost:8000
4 changes: 2 additions & 2 deletions frontend/src/api/api-routes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const UPLOAD_PHOTO_FOR_DETECTION_ROUTE = '/upload'
export const UPLOAD_PHOTO_FOR_DETECTION_ROUTE = '/analyses/'
export const TUTORIAL_FEEDBACK_ROUTE = '/tutorial-feedback'
export const IDENTIFICATION_FEEDBACK_ROUTE = '/identification-feedback'
export const IDENTIFICATION_DUMMY_ROUTE = '/identification-dummy'
export const ASK_FOR_OPINION_ROUTE = 'http://localhost:8000/api/requests/'
export const ASK_FOR_OPINION_ROUTE = '/requests/'
4 changes: 3 additions & 1 deletion frontend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ register()
const pinia = createPinia()

// the FastAPI backend
axios.defaults.baseURL = '/api/'
const apiHost = import.meta.env.VITE_API_HOST || 'http://basegun-backend:5000'

axios.defaults.baseURL = apiHost + '/api/'

// Register all icons
addIcons(...Object.values(icons))
Expand Down
16 changes: 3 additions & 13 deletions frontend/src/views/InstructionsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@ const router = useRouter()
const handledImageTypes = 'image/jpeg, image/png, image/tiff, image/webp, image/bmp, image/gif'
async function uploadImage (base64: string, fileName: string) {
const file = await srcToFile(base64, fileName, 'image/jpeg')
const fd = new FormData()
fd.append('image', file, file.name)
fd.append('date', '' + (Date.now() / 1000)) // date.now gives in milliseconds, convert to seconds
try {
const { data } = await axios.post('/upload', fd)
const { data } = await axios.post('/analyses/', {
"picture": base64
})
resultStore.$patch({
typology: data.label,
confidence: data.confidence,
Expand Down Expand Up @@ -81,12 +77,6 @@ function resizeImage (uploadedFile: File) {
})
}
async function srcToFile (src: string, fileName: string, mimeType: string) {
const res = await fetch(src)
const buf = await res.arrayBuffer()
return new File([buf], fileName, { type: mimeType })
}
function onFileSelected (event: InputEvent & { target: InputEvent['target'] & { files: File[] } }) {
loading.value = true
const uploadedFile = event.target?.files[0]
Expand Down
10 changes: 1 addition & 9 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import {
vueDsfrComponentResolver,
} from '@gouvminint/vue-dsfr'

const apiHost = process.env.API_HOST || 'http://basegun-backend:5000'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
Expand Down Expand Up @@ -100,12 +98,6 @@ export default defineConfig({
},
},
server: {
host: true,
proxy: {
'^/api': {
target: `${apiHost}`,
changeOrigin: true,
},
},
host: true
},
})

0 comments on commit 272c59a

Please sign in to comment.