[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 | package main | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
|  | 	"embed" | ||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"html/template" | 	"html/template" | ||||||
| @ -8,6 +9,8 @@ import ( | |||||||
| 	"log" | 	"log" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"time" | 	"time" | ||||||
|  | 
 | ||||||
|  | 	"gitea.hbanafa.com/hesham/viddl/resources" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const ( | 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() { | func main() { | ||||||
| 
 | 
 | ||||||
|     handler := http.NewServeMux() |     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