Created
July 29, 2019 22:19
-
-
Save parzibyte/e4086ed1b65d841629d871842146174d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Ejemplo 5: Servir archivos, por ejemplo imágenes, HTML, vídeos, etcétera en | |
una ruta que no es la raíz | |
@author parzibyte | |
*/ | |
package main | |
import ( | |
"fmt" // Imprimir en consola | |
"log" //Loguear si algo sale mal | |
"net/http" // El paquete HTTP | |
) | |
func main() { | |
http.Handle("/archivos/", http.StripPrefix("/archivos/", http.FileServer(http.Dir("./archivos")))) | |
direccion := ":8080" // Como cadena, no como entero; porque representa una dirección | |
fmt.Println("Servidor listo escuchando en " + direccion) | |
log.Fatal(http.ListenAndServe(direccion, nil)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment