diff --git a/01-introduction/es/11-spark_handling_get_requests-lecture.srt b/01-introduction/es/11-spark_handling_get_requests-lecture.srt index 85fa577..1f1c994 100644 --- a/01-introduction/es/11-spark_handling_get_requests-lecture.srt +++ b/01-introduction/es/11-spark_handling_get_requests-lecture.srt @@ -3,353 +3,348 @@ 2 00:00:00,350 --> 00:00:04,660 -So in this optional segment, -we're going to go over SPARK +En este vídeo opcional +vamos a analizar con un poco 3 00:00:04,660 --> 00:00:06,910 -routes in a little -more detail. +más de detalle las +rutas de Spark. 4 00:00:06,910 --> 00:00:09,360 -Now, for the blog project, we're -going to actually give +Para el proyecto del blog, +vamos a proporcionarte 5 00:00:09,360 --> 00:00:10,690 -you must of the SPARK code. +la mayoría del código Spark. 6 00:00:10,690 --> 00:00:13,650 -But just so you understand -what's happening, we wanted to +Queríamos hacer esta introducción +sobre cómo funcionan las rutas 7 00:00:13,650 --> 00:00:17,320 -give you this introduction to -how routes work in SPARK so +en Spark, simplemente para que +entiendas qué está ocurriendo, 8 00:00:17,320 --> 00:00:18,340 -that when you look -at the code, you +para que cuando mires el código, 9 00:00:18,340 --> 00:00:19,770 -understand what's happening. +comprendas qué está haciendo. 10 00:00:19,770 --> 00:00:22,450 -So the anatomy of a -SPARK application. +Entonces, la anatomía de una +aplicación Spark es la siguiente. 11 00:00:22,450 --> 00:00:26,630 -On the outside, you have your -web server, which is Jetty. +En la parte de afuera tienes tu +servidor web, que es Jetty. 12 00:00:26,630 --> 00:00:29,470 -So SPARK has a embedded -Jetty server. +Así que Spark tiene un servidor +Jetty embebido, 13 00:00:29,470 --> 00:00:32,810 -So when you create a route, -Jetty is automatically started +de forma que cuando creas una ruta, +Jetty se inicia automáticamente 14 00:00:32,810 --> 00:00:34,940 -for you in a background -thread. +en un hilo en segundo plano. 15 00:00:34,940 --> 00:00:41,290 -And inside, you have a SPARK -handler, such that when a +En la parte interna, tienes un +manejador de Spark, de forma que 16 00:00:41,290 --> 00:00:44,010 -request comes into Jetty, -Jetty forwards it +cuando entra una petición a +Jetty, éste la reenvía 17 00:00:44,010 --> 00:00:45,630 -to the SPARK handler. +al manejador de Spark. 18 00:00:45,630 --> 00:00:48,410 -And then within the SPARK -handler, you have one or more +Una vez en el manejador de +Spark, tienes una o más 19 00:00:48,410 --> 00:00:54,920 -routes, for example, get/, -or get/test, and so on. +rutas, por ejemplo, "GET /", +o "GET /test", y así sucesivamente. 20 00:00:54,920 --> 00:00:59,040 -And when you come to this web -server from a browser, you +Cuando accedes a este servidor +web desde un navegador, 21 00:00:59,040 --> 00:01:03,280 -make a request, say, to a local -host, that turns into a +haces una petición, digamos, a +localhost, esto se convierte en 22 00:01:03,280 --> 00:01:07,420 -get/ to local host, port -80 by default, but +"GET /" en localhost, con 80 +como puerto por defecto, aunque 23 00:01:07,420 --> 00:01:08,910 -you can change that. +puedes cambiarlo. 24 00:01:08,910 --> 00:01:12,780 -And that request goes to Jetty, -which, in turn, gets +Y esa petición va a Jetty, +que, a su vez, la pasa 25 00:01:12,780 --> 00:01:15,160 -passed to the SPARK route -handler, which, in turn, finds +al manejador de rutas de +Spark, que, a su vez, localiza 26 00:01:15,160 --> 00:01:18,320 -the correct route, which, in -this case, is the / route. +la ruta correcta, que, en +este caso, es la ruta "/". 27 00:01:18,320 --> 00:01:20,510 -The handler for that -route is executed +Se ejecuta el manejador +para esa ruta 28 00:01:20,510 --> 00:01:23,050 -and a response returned. +y se devuelve una respuesta. 29 00:01:23,050 --> 00:01:24,840 -So let's look at the code. +Echemos un vistazo al código. 30 00:01:24,840 --> 00:01:27,805 -So here's an application that -I wrote a little while ago. +Aquí tenemos una aplicación +que escribí hace un rato. 31 00:01:27,805 --> 00:01:31,760 -It's similar to what we had in -our SPARK Hello World, but +Es similar a la que teníamos en +"SparkHelloWorld", pero 32 00:01:31,760 --> 00:01:33,270 -with a few more routes. +con unas cuantas rutas más. 33 00:01:33,270 --> 00:01:34,860 -So we have our main method. +Aquí tenemos nuestro método "main". 34 00:01:34,860 --> 00:01:37,330 -And we have three routes -to find, each +Y tenemos tres rutas, 35 00:01:37,330 --> 00:01:38,880 -with a method Spark.get. +cada una con un método "Spark.get". 36 00:01:38,880 --> 00:01:42,160 -So we have get here, -get, and get. +Tenemos un "get" aquí, otro +aquí, y otro aquí. 37 00:01:42,160 --> 00:01:44,030 -And we define our routes. +Y definimos nuestras tres rutas, 38 00:01:44,030 --> 00:01:48,320 -Are three routes are /, and -/test, and then a funny +que son "/", +"/test", y esta tan 39 00:01:48,320 --> 00:01:50,450 -looking one here, -/echo/:thing. +curiosa aquí, +"/echo/:thing". 40 00:01:50,450 --> 00:01:52,240 -We'll get to that in a minute. +Llegaremos a eso en un minuto. 41 00:01:52,240 --> 00:01:55,510 -But for a request to /, it'll -go to this handler. +Para una petición a "/", +irá a este manejador. 42 00:01:55,510 --> 00:01:57,900 -For /test, it'll go -to this handler. +Para "/test", irá +a este manejador. 43 00:01:57,900 --> 00:02:00,090 -And let me show you what -that looks like. +Permíteme que te enseñe +cómo funciona. 44 00:02:00,090 --> 00:02:02,330 -I'm going to start -this program up. +Voy a ejecutar +este programa. 45 00:02:02,330 --> 00:02:05,870 -So SPARK is listening -on 4567 by default. +Spark está escuchando por +defecto en el puerto 4567. 46 00:02:05,870 --> 00:02:07,950 -So I'm going to go to -this web page here. +Voy a ir a esta +página web aquí. 47 00:02:07,950 --> 00:02:10,930 -And / goes to Hello World. +"/" va a "Hello World", 48 00:02:10,930 --> 00:02:14,750 -/test goes to this -is a test page. +y "/test" a "This +is a test page". 49 00:02:14,750 --> 00:02:16,540 -And that's the first two. +Y esas son las dos primeras. 50 00:02:16,540 --> 00:02:19,600 -Now let's look at a third route, -which is a little bit +Ahora vamos a echar un vistazo +a la tercera ruta, que es un poco 51 00:02:19,600 --> 00:02:20,340 -more interesting. +más interesante. 52 00:02:20,340 --> 00:02:23,990 -So the third route is defined -as /echo/:thing. +La tercera ruta está definida +como "/echo/:thing". 53 00:02:23,990 --> 00:02:26,460 -Now, whole: thing is a wild -card, in this case. +":thing" es un comodín, +en este caso, 54 00:02:26,460 --> 00:02:31,210 -And this route will match any -path that starts with /echo/ +y esta ruta coincidirá con +cualquiera que comience por "/echo/" 55 00:02:31,210 --> 00:02:33,930 -and then has any segment -after that. +y que tenga cualquier segmento +a continuación. 56 00:02:33,930 --> 00:02:36,940 -So when the request comes in, -SPARK will match this route +Entonces, cuando llega la petición, +Spark la emparejará con 57 00:02:36,940 --> 00:02:39,860 -for /echo/cat or /dog. +"/echo/cat" o "/echo/dog". 58 00:02:39,860 --> 00:02:43,990 -And you can get the value of -this thing variable, or wild +Puedes obtener el valor de +esta variable ":thing", o 59 00:02:43,990 --> 00:02:46,800 -card, by calling request.params, -and then +comodín, llamando a +"request.params(":thing")", 60 00:02:46,800 --> 00:02:50,460 -(":thing:"), in this case, -to match the :thing here. +en este caso, para hacer +coincidir la variable ":thing" aquí. 61 00:02:50,460 --> 00:02:52,560 -So let's look at that -in a web browser. +Echemos un vistazo a eso +en un navegador web. 62 00:02:52,560 --> 00:02:54,940 -So I'm going to get -rid of this. +Voy a suprimir esto y 63 00:02:54,940 --> 00:02:56,190 -And I'm going to -say /echo/cat. +voy a poner "/echo/cat". 64 00:02:56,190 --> 00:02:59,130 65 00:02:59,130 --> 00:03:00,560 -And it echoes cat. +Y devuelve "cat". 66 00:03:00,560 --> 00:03:03,560 -And that happens because -what we return here is +Eso ocurre porque lo +que devolvemos aquí es 67 00:03:03,560 --> 00:03:06,125 -request.params(":thing"). +"request.params(":thing")". 68 00:03:06,125 --> 00:03:09,760 -And if I change that to dog, -it will return dog. +Y si cambio eso por "dog", +devolverá "dog". 69 00:03:09,760 --> 00:03:13,410 -So this is just an introduction -to route handling +Así que esto es simplemente una +introducción al manejo de rutas 70 00:03:13,410 --> 00:03:17,600 -in SPARK showing how you can -define routes for multiple +en Spark, que muestra cómo +puedes definir rutas para 71 00:03:17,600 --> 00:03:21,500 -paths in your application, and -how you can use wildcarding to +múltiples URLs en tu aplicación, +y cómo puedes usar comodines para 72 00:03:21,500 --> 00:03:23,950 -give a little more dynamic -behavior to the routes that +dar un poco de comportamiento +dinámico a las rutas que 73 00:03:23,950 --> 00:03:25,010 -you've defined. +has definido. 74 00:03:25,010 --> 00:03:27,790 -And in the next section, we'll -look at form handling using +En la siguiente sección, +veremos el manejo de formularios 75 00:03:27,790 --> 00:03:31,140 -routes mapped to post requests -instead of get. +usando rutas mapeadas a peticiones +"POST" en lugar de "GET". 76 -00:03:31,140 --> 00:03:32,390 \ No newline at end of file +00:03:31,140 --> 00:03:32,390