Spaces:
Sleeping
Sleeping
pierrelissope
commited on
Commit
·
c3a38ec
1
Parent(s):
6d73052
feat: added backend core
Browse files- Dockerfile +1 -1
- back.py +51 -0
- front/dist/assets/index-C18QItnI.js +0 -0
- front/dist/index.html +1 -1
- front/src/VerificationScene.tsx +2 -2
Dockerfile
CHANGED
@@ -15,4 +15,4 @@ COPY --chown=user . /app
|
|
15 |
# Changer d'utilisateur
|
16 |
USER user
|
17 |
|
18 |
-
CMD
|
|
|
15 |
# Changer d'utilisateur
|
16 |
USER user
|
17 |
|
18 |
+
CMD uvicorn main:app --host localhost --port 7860 & uvicorn back:app --host localhost --port 8000
|
back.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import time
|
2 |
+
from pydantic import BaseModel
|
3 |
+
import base64
|
4 |
+
from fastapi import FastAPI, APIRouter
|
5 |
+
from fastapi.middleware.cors import CORSMiddleware
|
6 |
+
|
7 |
+
app = FastAPI()
|
8 |
+
|
9 |
+
origins = [
|
10 |
+
"http://localhost:7860", # Exemple d'origine (ajoutez vos origines ici)
|
11 |
+
"https://example.com",
|
12 |
+
]
|
13 |
+
|
14 |
+
app.add_middleware(
|
15 |
+
CORSMiddleware,
|
16 |
+
allow_origins=origins, # Liste des origines autorisées
|
17 |
+
allow_credentials=True,
|
18 |
+
allow_methods=["*"], # Autorise toutes les méthodes (GET, POST, etc.)
|
19 |
+
allow_headers=["*"], # Autorise tous les en-têtes
|
20 |
+
)
|
21 |
+
|
22 |
+
class ImageData(BaseModel):
|
23 |
+
image: str
|
24 |
+
|
25 |
+
class ImagesData(BaseModel):
|
26 |
+
idCard: str
|
27 |
+
profileImage: str
|
28 |
+
|
29 |
+
@app.post("/uploadpdf")
|
30 |
+
async def upload_pdf(image_data: ImageData):
|
31 |
+
# Extraire le contenu Base64
|
32 |
+
header, encoded = image_data.image.split(',', 1) # Séparer le header des données
|
33 |
+
binary_data = base64.b64decode(encoded) # Décoder les données
|
34 |
+
|
35 |
+
time.sleep(20);
|
36 |
+
|
37 |
+
return {"message": "Image reçue et sauvegardée"}
|
38 |
+
|
39 |
+
@app.post("/uploadids")
|
40 |
+
async def upload_ids(images_data: ImagesData):
|
41 |
+
header, encoded = images_data.idCard.split(',', 1) # Séparer le header des données
|
42 |
+
id_card_binary_data = base64.b64decode(encoded)
|
43 |
+
|
44 |
+
header, encoded = images_data.idCard.split(',', 1) # Séparer le header des données
|
45 |
+
profile_image_binary_data = base64.b64decode(encoded)
|
46 |
+
|
47 |
+
time.sleep(20);
|
48 |
+
|
49 |
+
return {"message": "Image reçue et sauvegardée"}
|
50 |
+
|
51 |
+
|
front/dist/assets/index-C18QItnI.js
DELETED
The diff for this file is too large to render.
See raw diff
|
|
front/dist/index.html
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
7 |
<title>Vite + React + TS</title>
|
8 |
-
<script type="module" crossorigin src="/assets/index-
|
9 |
<link rel="stylesheet" crossorigin href="/assets/index-p_2jy9GY.css">
|
10 |
</head>
|
11 |
<body>
|
|
|
5 |
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
7 |
<title>Vite + React + TS</title>
|
8 |
+
<script type="module" crossorigin src="/assets/index-B9x6gsXC.js"></script>
|
9 |
<link rel="stylesheet" crossorigin href="/assets/index-p_2jy9GY.css">
|
10 |
</head>
|
11 |
<body>
|
front/src/VerificationScene.tsx
CHANGED
@@ -39,7 +39,7 @@ export default function VerificationScene() {
|
|
39 |
setLoading: (n: boolean) => void,
|
40 |
) => {
|
41 |
try {
|
42 |
-
const response = await fetch("
|
43 |
method: "POST",
|
44 |
headers: {
|
45 |
"Content-Type": "application/json",
|
@@ -53,7 +53,7 @@ export default function VerificationScene() {
|
|
53 |
|
54 |
const data = await response.json();
|
55 |
console.log("Image envoyée avec succès:", data);
|
56 |
-
setLoading(
|
57 |
} catch (error) {
|
58 |
console.error("Erreur:", error);
|
59 |
setLoading(false);
|
|
|
39 |
setLoading: (n: boolean) => void,
|
40 |
) => {
|
41 |
try {
|
42 |
+
const response = await fetch("http://localhost:8000/uploadpdf", {
|
43 |
method: "POST",
|
44 |
headers: {
|
45 |
"Content-Type": "application/json",
|
|
|
53 |
|
54 |
const data = await response.json();
|
55 |
console.log("Image envoyée avec succès:", data);
|
56 |
+
setLoading(false);
|
57 |
} catch (error) {
|
58 |
console.error("Erreur:", error);
|
59 |
setLoading(false);
|