[WIP] settings up template and static files embedding
This commit is contained in:
		
							parent
							
								
									598fd51412
								
							
						
					
					
						commit
						5c7bfc21ed
					
				
							
								
								
									
										11
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								main.go
									
									
									
									
									
								
							| @ -1,6 +1,7 @@ | ||||
| package main | ||||
| 
 | ||||
| import ( | ||||
| 	"embed" | ||||
| 	"encoding/json" | ||||
| 	"fmt" | ||||
| 	"html/template" | ||||
| @ -8,6 +9,8 @@ import ( | ||||
| 	"log" | ||||
| 	"net/http" | ||||
| 	"time" | ||||
| 
 | ||||
| 	"gitea.hbanafa.com/hesham/viddl/resources" | ||||
| ) | ||||
| 
 | ||||
| const ( | ||||
| @ -77,6 +80,14 @@ func writeJSONResponse(w http.ResponseWriter, s string) http.ResponseWriter { | ||||
|      | ||||
| } | ||||
| 
 | ||||
| var templates *template.Template | ||||
| 
 | ||||
| func init() { | ||||
|      | ||||
|     log.Println("[ init ] Starting...") | ||||
|     templates = template.Must(template.ParseFS(resources.TemplatesFS, "templates/*.html")) | ||||
| 
 | ||||
| } | ||||
| func main() { | ||||
| 
 | ||||
|     handler := http.NewServeMux() | ||||
|  | ||||
							
								
								
									
										7
									
								
								resources/resources.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								resources/resources.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | ||||
| package resources | ||||
| 
 | ||||
| import "embed" | ||||
| 
 | ||||
| //go:embed gitea.hbanafa.com/hesham/viddl/resources
 | ||||
| var TemplatesFS embed.FS | ||||
| 
 | ||||
| @ -1 +1 @@ | ||||
| <a href="{{ . }}" rel="nofollow" download>Download</a> | ||||
| <a href="{{ . }}" rel="" download target="_blank">Download</a> | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user