gabrielquiroz commited on
Commit
b568de0
verified
1 Parent(s): a966cb7

Upload 18 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,12 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ images/DNI.jpg filter=lfs diff=lfs merge=lfs -text
37
+ images/doc1.jpg filter=lfs diff=lfs merge=lfs -text
38
+ images/doc11.jpg filter=lfs diff=lfs merge=lfs -text
39
+ images/doc12.jpg filter=lfs diff=lfs merge=lfs -text
40
+ images/doc13.jpg filter=lfs diff=lfs merge=lfs -text
41
+ images/doc3.jpg filter=lfs diff=lfs merge=lfs -text
42
+ images/doc4.jpg filter=lfs diff=lfs merge=lfs -text
43
+ images/doc8.jpg filter=lfs diff=lfs merge=lfs -text
44
+ images/doc9.jpg filter=lfs diff=lfs merge=lfs -text
Dockerfile ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Usa una imagen base de Python
2
+ FROM python:3.12.7
3
+
4
+ # Establece el directorio de trabajo
5
+ WORKDIR /code
6
+
7
+ # Copia los archivos necesarios al contenedor
8
+ COPY ./requirements.txt /code/requirements.txt
9
+ RUN pip install --no-cache-dir -r /code/requirements.txt
10
+ RUN pip install fastapi uvicorn
11
+
12
+ COPY . .
13
+
14
+ RUN chmod -R 777 /code
15
+
16
+ # Comando para ejecutar la aplicaci贸n
17
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
images/DNI.jpg ADDED

Git LFS Details

  • SHA256: 9916ba092606a5393098f36b4aac41e320a0b5edbaa615ee061dbcf4993573c2
  • Pointer size: 131 Bytes
  • Size of remote file: 252 kB
images/doc1.jpg ADDED

Git LFS Details

  • SHA256: e5a27e26721adb20155c5f6a37e1bbe7c63b8fee032e5c6c711c4d4b29d55ffa
  • Pointer size: 131 Bytes
  • Size of remote file: 104 kB
images/doc10.jpg ADDED
images/doc11.jpg ADDED

Git LFS Details

  • SHA256: 627e31f3816a260cb0feaa919b302484d215297c408f249737bcd856ea3cf252
  • Pointer size: 131 Bytes
  • Size of remote file: 154 kB
images/doc12.jpg ADDED

Git LFS Details

  • SHA256: 11b9430a1d18e2a419d3e777ac1e4d387f12248d6b206667105756f63afcd654
  • Pointer size: 131 Bytes
  • Size of remote file: 156 kB
images/doc13.jpg ADDED

Git LFS Details

  • SHA256: 36aa43af82b3f0d0924e6f1411e2b12be3b785c914277f1899994b38a4551244
  • Pointer size: 131 Bytes
  • Size of remote file: 157 kB
images/doc2.jpg ADDED
images/doc3.jpg ADDED

Git LFS Details

  • SHA256: 532707c8fac4e7be60de3201d30ae0aba365b82028e71e3a3bbe7d96ae1b0453
  • Pointer size: 131 Bytes
  • Size of remote file: 185 kB
images/doc4.jpg ADDED

Git LFS Details

  • SHA256: 8c38db73fe4d091cd026b6ba92292b18c24f51ca907f92b413e2a52ba770c70d
  • Pointer size: 131 Bytes
  • Size of remote file: 108 kB
images/doc5.jpg ADDED
images/doc6.jpg ADDED
images/doc7.jpg ADDED
images/doc8.jpg ADDED

Git LFS Details

  • SHA256: c35c61d91b2438e41a791eb63f49365c1064401a8d63d881913ee0dad2a99d0c
  • Pointer size: 131 Bytes
  • Size of remote file: 106 kB
images/doc9.jpg ADDED

Git LFS Details

  • SHA256: 02eb4ee7b748c81d1a507724f0883b5e0db8316da79ae98b4ad27ff13142782c
  • Pointer size: 131 Bytes
  • Size of remote file: 129 kB
main.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, Form, Request
2
+ from fastapi.responses import RedirectResponse
3
+ from fastapi.staticfiles import StaticFiles
4
+ from fastapi.templating import Jinja2Templates
5
+ import os
6
+ import random
7
+ import requests
8
+
9
+ GOOGLE_SHEETS_URL = 'https://script.google.com/macros/s/AKfycbxsrkX8g7HkcmrX_t6YiHMcj_e51ZAxLaLC7OlcAjFP1LI1XoJKAOl0xmAKdl_05IiY/exec'
10
+
11
+ app = FastAPI()
12
+
13
+ # Montar la carpeta de im谩genes como archivos est谩ticos
14
+ app.mount("/images", StaticFiles(directory="images"), name="images")
15
+
16
+ # Configurar Jinja2 templates
17
+ templates = Jinja2Templates(directory="templates")
18
+
19
+ @app.get("/")
20
+ async def index(request: Request):
21
+ images_folder = 'images'
22
+ images = os.listdir(images_folder) if os.path.exists(images_folder) else []
23
+ image_name = random.choice(images) if images else ''
24
+ return templates.TemplateResponse("index.html", {"request": request, "image_name": image_name})
25
+
26
+ @app.post("/submit")
27
+ async def submit(
28
+ dni: str = Form(...),
29
+ primer_apellido: str = Form(...),
30
+ segundo_apellido: str = Form(...),
31
+ pre_nombres: str = Form(...),
32
+ fecha_nacimiento: str = Form(...),
33
+ ubigeo: str = Form(...),
34
+ sexo: str = Form(...),
35
+ estado_civil: str = Form(...),
36
+ fecha_inscripcion: str = Form(...),
37
+ fecha_emision: str = Form(...),
38
+ fecha_caducidad: str = Form(...),
39
+ image_name: str = Form(...),
40
+ tiempo: str = Form(...)
41
+ ):
42
+ data = {
43
+ 'dni': dni,
44
+ 'primer_apellido': primer_apellido,
45
+ 'segundo_apellido': segundo_apellido,
46
+ 'pre_nombres': pre_nombres,
47
+ 'fecha_nacimiento': fecha_nacimiento,
48
+ 'ubigeo': ubigeo,
49
+ 'sexo': sexo,
50
+ 'estado_civil': estado_civil,
51
+ 'fecha_inscripcion': fecha_inscripcion,
52
+ 'fecha_emision': fecha_emision,
53
+ 'fecha_caducidad': fecha_caducidad,
54
+ 'image_name': image_name,
55
+ 'tiempo': tiempo
56
+ }
57
+
58
+ try:
59
+ response = requests.post(GOOGLE_SHEETS_URL, json=data)
60
+ if response.status_code == 200:
61
+ print("Datos enviados a Google Sheets correctamente.")
62
+ else:
63
+ print("Error al enviar a Google Sheets:", response.text)
64
+ except Exception as e:
65
+ print("Excepci贸n al enviar a Google Sheets:", e)
66
+
67
+ return RedirectResponse(url="/", status_code=303)
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ fastapi==0.110.2
2
+ uvicorn==0.29.0
3
+ jinja2==3.1.4
4
+ requests==2.31.0
5
+ python-multipart==0.0.9
templates/index.html ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Ingreso de datos</title>
5
+ <script>
6
+ let startTime;
7
+ function empezar() {
8
+ document.getElementById('inicio').style.display = 'none';
9
+ document.getElementById('contenido').style.display = 'flex';
10
+ startTime = Date.now();
11
+ }
12
+
13
+ function prepararEnvio() {
14
+ const tiempoTranscurrido = Math.floor((Date.now() - startTime) / 1000);
15
+ document.getElementById('tiempo').value = tiempoTranscurrido;
16
+ return true;
17
+ }
18
+ </script>
19
+ </head>
20
+ <body style="font-family: Arial, sans-serif; text-align: center; margin: 30px;">
21
+
22
+ <div id="inicio">
23
+ <!-- Imagen portada inicial -->
24
+ <img src="/images/DNI.jpg" width="400" alt="DNI Portada" style="margin-bottom: 30px;">
25
+
26
+ <h2>Ingresa todos los datos solicitados.<br>* Escribe los datos con may煤sculas y las fechas en el formato indicado. *<br>Da clic en el bot贸n Empezar cuando est茅s listo.</h2>
27
+ <button onclick="empezar()" style="padding:10px 20px; font-size:16px; cursor:pointer;">Empezar</button>
28
+ </div>
29
+
30
+ <div id="contenido" style="display:none; justify-content: center; align-items: flex-start; gap: 50px;">
31
+
32
+ <!-- Imagen a la izquierda -->
33
+ <div id="imagen" style="flex: 1; text-align: center;">
34
+ <img src="/images/{{ image_name }}" width="800" alt="Documento" style="margin-bottom: 20px;">
35
+ </div>
36
+
37
+ <!-- Formulario a la derecha -->
38
+ <div id="formulario" style="flex: 1; text-align: left;">
39
+ <form method="POST" action="/submit" onsubmit="return prepararEnvio()" style="max-width: 400px; margin: 0 auto;">
40
+ <label>DNI:</label><br>
41
+ <input type="text" name="dni" required style="width: 100%; padding: 8px; margin-top:5px;"><br>
42
+
43
+ <label>Primer Apellido:</label><br>
44
+ <input type="text" name="primer_apellido" required style="width: 100%; padding: 8px; margin-top:5px;"><br>
45
+
46
+ <label>Segundo Apellido:</label><br>
47
+ <input type="text" name="segundo_apellido" required style="width: 100%; padding: 8px; margin-top:5px;"><br>
48
+
49
+ <label>Pre Nombres:</label><br>
50
+ <input type="text" name="pre_nombres" required style="width: 100%; padding: 8px; margin-top:5px;"><br>
51
+
52
+ <label>Fecha de nacimiento (DD/MM/AA):</label><br>
53
+ <input type="text" name="fecha_nacimiento" placeholder="DD/MM/AA" required style="width: 100%; padding: 8px; margin-top:5px;"><br>
54
+
55
+ <label>Ubigeo:</label><br>
56
+ <input type="text" name="ubigeo" required style="width: 100%; padding: 8px; margin-top:5px;"><br>
57
+
58
+ <label>Sexo (F/M):</label><br>
59
+ <input type="text" name="sexo" required style="width: 100%; padding: 8px; margin-top:5px;"><br>
60
+
61
+ <label>Estado Civil (C/S):</label><br>
62
+ <input type="text" name="estado_civil" required style="width: 100%; padding: 8px; margin-top:5px;"><br>
63
+
64
+ <label>Fecha Inscripci贸n (DD/MM/AA):</label><br>
65
+ <input type="text" name="fecha_inscripcion" placeholder="DD/MM/AA" required style="width: 100%; padding: 8px; margin-top:5px;"><br>
66
+
67
+ <label>Fecha Emisi贸n (DD/MM/AA):</label><br>
68
+ <input type="text" name="fecha_emision" placeholder="DD/MM/AA" required style="width: 100%; padding: 8px; margin-top:5px;"><br>
69
+
70
+ <label>Fecha Caducidad (DD/MM/AA):</label><br>
71
+ <input type="text" name="fecha_caducidad" placeholder="DD/MM/AA" required style="width: 100%; padding: 8px; margin-top:5px;"><br>
72
+
73
+ <input type="hidden" name="image_name" value="{{ image_name }}">
74
+ <input type="hidden" name="tiempo" id="tiempo" value="0">
75
+
76
+ <button type="submit" style="margin-top: 20px; padding: 10px 20px; font-size: 16px; cursor:pointer;">Enviar</button>
77
+ </form>
78
+ </div>
79
+ </div>
80
+
81
+ </body>
82
+ </html>