Programación de Aplicaciones Web (I) en URJC para Universidad

Diapositivas de URJC sobre Programación de Aplicaciones Web (I). El Pdf aborda los fundamentos de la programación web, centrándose en verbos HTTP como GET y el formato JSON, con ejemplos en Python para manipulación de datos. Es un recurso de Informática para estudiantes universitarios.

Mostra di più

23 pagine

Programación de Aplicaciones Web 9
Programación de Aplicaciones Web (I)
Programación en Entornos de Red
GRADO EN INGENIERÍA BIOMÉDICA 2017-2018
Juan Gonzalez Gomez <juan.gonzalez.gomez@urjc.es>,
Agustín Santos <agustin.santos@urjc.es>
Verbos HTTP: GET
Lo usamos para obtener un fichero Html, texto, imagen, etc.

Visualizza gratis il Pdf completo

Registrati per accedere all’intero documento e trasformarlo con l’AI.

Anteprima

Programación en Entornos de Red

GRADO EN INGENIERÍA BIOMÉDICA 2017-2018 Juan Gonzalez Gomez , Agustín Santos Verbos HTTP: GET

Método GET: Solicitud HTTP

Path to source on Web Server Parameters Protocol Version Browser support Http request method GET/profile.jsp?user=abhi&course=java HTTP/1.1 Host: www.studytonight.com request header User-Agent: Mozilla/5.0 Accept: text/xml, text/html, text/plain, image/jpeg Accept-Language: en-us, en Accept-Encoding: gzip Keep-Alive: 300 Connection: keep-alive Lo usamos para obtener un fichero Html, texto, imagen, etc.GET

Características del Método GET

  • Cualquier tipo de fichero (html, texto, imagen, etc.)
  • Se puede repetir sin efectos (es idempotente)
  • Podemos dar parámetros o argumentos
  • Una página Html puede invocar múltiples peticiones . No mantiene la conexión
  • Se puede "cachear" web server HTML, images, text files, etcGET

Ejemplo de Solicitud GET

GET /hello.htm HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT) Host: www.tutorialspoint.com Accept-Language: en-us Accept-Encoding: gzip, deflate Connection: Keep-Alive HTTP/1.1 200 OK Date: Mon, 27 Jul 2009 12:28:53 GMT Server: Apache/2.2.14 (Win32) Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT ETag: "34aa387-d-1568eb00" Vary: Authorization, Accept Accept-Ranges : bytes Content-Length: 88 Content-Type: text/html Connection: Closed

Hello, World !< /h1>

GET

Detalles de Peticiones GET en Navegador

Return to list view Details tabs Inspector Console ℮ Debugger Style Editor Timeline etwork > V Method File Headers Cookies Params Response Timings Preview 200 GET The_Rite_of_Spring en.wikipec Request URL: http://en.wikipedia.org/wiki/The_Rite_of_Spring Request method: GET 200 GET load.php?debug=false&lang ... bits.wikim Status code: · 200 OK 200 GET load.php?debug=false&lang ... bits.wikim Q Filter headers . 200 GET load.php?debug=false&lang ... bits.wikim Response headers (0.640 KB) . 200 GET load.php?debug=false&lang ... bits.wikim Accept-Ranges: "bytes" 200 GET 15px-Cscr-featured.svg.png upload.wik Age: "25857" 200 GET 350px-NikolaiRoerichRite1.jpg upload.wik Cache-Control: "private, s-maxage=0, max-age=0, must-revalidate" 200 GET 170px-Igor_Stravinsky_as_dr ... upload.wik . 200 GET 170px-Bakst_daighilev.jpg upload.wik - inn CET Dailindmanflavanac All HTML CSS JS XHR Fonts Images Media Flash Other 46 requests, 1,290.23 KB, 0.78 s Clear X Edit and Resend Raw headers Connection: "keep-alive" Content-Encoding: "gzip" Content-Language: "en"Verbos HTTP: POST

Método POST: Envío de Información

Path to source on Web Server Protocol Version Browser support Http request method request header POST/profile.jsp HTTP/1.1 Host: www.studytonight.com User-Agent: Mozilla/5.0 Accept: text/xml, text/html, text/plain, image/jpeg Accept-Language: en-us, en Accept-Encoding: gzip Keep-Alive: 300 Connection: keep-alive user=abhi&course=java parameter inside message body Lo usamos para mandar información al servidorPOST

Características del Método POST

  • Lo usamos para mandar información
  • No se puede "cachear"
  • No es idempotente (puede tener efectos secundarios)
  • En Html suele redirigir a otra página
  • Los datos viajan en el cuerpo, no en los argumentos web server HTML, images, text files, etcPOST

Ejemplo de Solicitud POST

POST /cgi-bin/process.cgi HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT) Host: www. tutorialspoint.com Content-Type: text/xml; charset=utf-8 Content-Length: 88 Accept-Language: en-us Accept-Encoding: gzip, deflate Connection: Keep-Alive stringPOST

Respuesta HTTP a Solicitud POST

HTTP/1.1 200 OK Date: Mon, 27 Jul 2009 12:28:53 GMT Server: Apache/2.2.14 (Win32) Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT ETag : "34aa387-d-1568eb00" Vary: Authorization, Accept Accept-Ranges: bytes Content-Length: 88 Content-Type: text/html Connection: Closed

Request Processed Successfully

Formularios HTML

Ejemplo de Formulario HTML

A Run > First name :< br>
Last name :< br>

If you click the "Submit" button, the form-data will be sent to a page called "/action_page.php" .< /p>

First name: |Mickey Last name: Mouse

First name :< br>
Last name :< br>

If you click the "Submit" button, the form-data will be sent to a page called "/action_page.php" .< /p> Run > Result Size: 825 x 901 Submitted Form Data Your input was received as: firstname=Mickey&lastname=Mouse The server has processed your input and returned this answer. Note: This tutorial will not teach you how servers are processing input. Processing input is explained in our PHP tutorial. https://www.w3schools.com/html/html_forms.asp Result Size: 825 x 770 Submit If you click the "Submit" button, the form-data will be sent to a page called "/action_page.php".

Código HTML de Formulario con Método GET

First name :< br>
Last name :< br>

If you click the "Submit" button, the form-data will be sent to a page called "/action_page.php" .< /p>

Ejercicio 1: Formulario y Método GET

Run > Result Size: 825 x 433 Submitted Form Data First name :< br> Your input was received as:
firstname=Mickey&lastname=Mouse Last name :< br>

The server has processed your input and returned this answer. Note: This tutorial will not teach you how servers are processing input. Processing input is explained in our PHP tutorial.

If you click the "Submit" button, the form-data will be sent to a page called "/action_page.php" .< /p>

Elements Console Sources Network Performance Memory Application Security Audits × Filter Hide data URLs XHR JS CSS Img Media Font Doc WS Manifest Other 2000 ms 4000 ms 6000 m 8000 ms 10000 ms 12000 ms 14000 ms 16000 ma 20000 ms 22000 m 24000 ms 26000 ms 28000 ms 30000 ma 32000 ma 34000 ms 30000 ms 38000 ms 40000 ms 42000 ms 44000 ma Name x Headers |Preview Response Cookies Timing de_oe=ChMIvpLJ5p7c2QIVQjLTCh33Zg-DEAAYACDQ3Yov;met ...; eid1=871060;ecn1=1;etm1=0;eid2=2;ecn2=1;etm2=10; ¥ General Request URL: https://www.w3schools.com/action_page.php?firstname-Mickey&lastname-Mouse de_oe=ChMIvpL/5p7c2QIVQjLTCh33Zg-DEAAYACDQ3Yov;met=1;×tamp=1520495431195;eid1=2;ecm1=0;etm1=10; action_page.php?firstname=Mickey&lastname=Mouse Request Method: GET Status Code: · 200 Remote Address: 192.229.133.221:443 Referrer Policy: no-referrer-when-downgrade Y Response Headers cache-control: public content-encoding: gzip content-length: 574 content-type: text/html 4 requests | 1.7 KB transferred : Console × top Filter Default levels * * Group similar hidden

  1. Prueba con el formulario de ejemplo
  2. Prueba con y sin method="GET"
  3. Cambia los datos e identifica el lugar en el que se mandan al servidor
  4. Comprueba que el método de llamada es GET View: Group by frame Preserve log Disable cache Offline Online 18000 ms - de_oe=ChMIvpL/5p7c2QIVQjLTCh33Zg-DEAAYACDQ3Yov;met=1;×tamp=1520495461198;eid1=2;ecm1=0;etm1=30; date: Thu, 08 Mar 2018 07:50:48 GMT server: Microsoft-IIS/7.5

Ejercicio 2: Formulario y Método POST

Submitted Form Data Your input was received as: firstname=Mickey&lastname=Mouse The server has processed your input and returned this answer. Note: This tutorial will not teach you how servers are processing input. Processing input is explained in our PHP tutorial. Elements Console Sources Network Performance Memory Application Security Audits × Name X Headers Preview Response Cookies Timing action_page.php ¥ General Request URL: https://www.w3schools.com/action_page. php Request Method: POST Status Code: 208 Remote Address: 192.229.133.221:443 Referrer Policy: no-referrer-when-downgrade ¥ Response Headers cache-control: public content-encoding: gzip content-length: 574 content-type: text/html date: Thu, 08 Mar 2018 08:04:06 GMT server: Microsoft-IIS/7.5 status: 200 vary: Accept-Encoding x-frame-options: SAMEORIGIN x-powered-by: PHP/5.4.2 x-powered-by: ASP. NET W Request Headers :authority: www.w3schools.com :method: POST :path: /action_page. php :scheme: https accept: text/html,application/xhtml+xml,application/xml;q=0.9, image/webp, image/apng,*/ *; q-0.8 accept-encoding: gzip, deflate, br accept-language: es-ES,es;q-0.9,en;q-0.8,fr;q=0.7 cache-control: max-age-0 content-length: 31 content-type: application/x-www-form-urlencoded 1 requests | 631 B transferred | Finish: 162 ms | DOMContentLoaded: 517 ms | Load: 521 ms : Console top Filter Default levels Y Group similar

  1. Vuelve a probar con el formulario de ejemplo
  2. Prueba poniendo method="POST"
  3. Cambia los datos e identifica el lugar en el que se mandan al servidor
  4. Comprueba que el método de llamada es POST
  5. Identifica todos los cambios en las cabeceras. ¿Se corresponde con lo explicado en clase? Group by frame Preserve log Disable cache Offline Online Filter Hide data URLs XHR JS CSS Img Media Font Doc WS Manifest Other 10 mg 20 m 5 ms 10 m 35 m 40 m 45 m 50 m 00 mg 70 m 75 m 05 m 90 ms 100 m 105 ms x View: ==PUT

Método PUT: Actualización de Información

  • Lo usamos para actualizar información
  • Muy parecido al POST. Pero se supone que ya hay información y queremos actualizar web server HTML, images, text files, etcDELETE

Método DELETE: Borrado de Información

  • Lo usamos para borrar información
  • No es idempotente
  • No se puede cachear web server HTML, images, text files, etc

Non hai trovato quello che cercavi?

Esplora altri argomenti nella Algor library o crea direttamente i tuoi materiali con l’AI.