Advertisement
teslariu

automatizar

Dec 2nd, 2022
711
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # cliente para cargar datos
  5.  
  6. import requests
  7. datos = [
  8.     {'nombre':'JOHN', 'cursos':4},
  9.     {'nombre':'HENRY', 'cursos':1},
  10.     {'nombre':'ANNE', 'cursos':6},
  11.     {'nombre':'KEVIN', 'cursos':3},
  12. ]
  13.  
  14. url = "http://localhost:5000/form"
  15.  
  16. for dato in datos:
  17.     r = requests.post(url, data=dato)
  18.     respuesta = r.content.decode("utf-8")
  19.     if "Datos guardados" in respuesta:
  20.         print(f"Datos del alumno {dato['nombre']} subidos correctamente")
  21.     else:
  22.         print(f"Datos del alumno {dato['nombre']} no subidos")
  23.         print(f"Error {r.status_code}")
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement