Skip to content

Commit

Permalink
chore: remove html templates
Browse files Browse the repository at this point in the history
  • Loading branch information
ramchaik committed Sep 3, 2024
1 parent 04dc158 commit 6efa8b6
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 560 deletions.
12 changes: 4 additions & 8 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ Nous consists of two main services:
│ ├── internal
│ ├── nous.db
│ ├── static
│ └── templates
├── docker-compose.yml
├── docs
│ ├── crag-architecture.png
Expand Down Expand Up @@ -192,7 +191,6 @@ The Golang server configuration manages various aspects of the web server, inclu
```go
type Config struct {
StaticPath string
TemplatesPath string
ServerAddr string
DatabasePath string
LLMBaseURL string
Expand All @@ -203,7 +201,6 @@ type Config struct {
#### Configuration Options

- `StaticPath`: Path to static files (default: `"../static"` relative to the executable)
- `TemplatesPath`: Path to HTML templates (default: `"../templates/*"` relative to the executable)
- `ServerAddr`: Address and port for the HTTP server (default: `:8080`)
- `DatabasePath`: Path to the SQLite database file (default: `"./nous.db"`)
- `LLMBaseURL`: URL of the LLM service (default: `"http://localhost:5000"`)
Expand All @@ -214,11 +211,10 @@ type Config struct {
You can customize these settings using environment variables:

1. `STATIC_PATH`: Set the path to static files
2. `TEMPLATES_PATH`: Set the path to HTML templates
3. `SERVER_ADDR`: Set the server address and port
4. `DATABASE_PATH`: Set the path to the SQLite database file
5. `LLM_BASE_URL`: Set the URL of the LLM service
6. `REDIS_ADDR`: Set the address of the Redis server
2. `SERVER_ADDR`: Set the server address and port
3. `DATABASE_PATH`: Set the path to the SQLite database file
4. `LLM_BASE_URL`: Set the URL of the LLM service
5. `REDIS_ADDR`: Set the address of the Redis server

Example:
```bash
Expand Down
52 changes: 25 additions & 27 deletions app/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,43 @@ import (

// Config holds all configuration for the application
type Config struct {
StaticPath string
TemplatesPath string
ServerAddr string
DatabasePath string
LLMBaseURL string
RedisAddr string
StaticPath string
ServerAddr string
DatabasePath string
LLMBaseURL string
RedisAddr string
}

// Load returns a new Config struct populated with values from environment variables or defaults
func Load() (*Config, error) {
exPath, err := getExecutablePath()
if err != nil {
return nil, err
}
exPath, err := getExecutablePath()
if err != nil {
return nil, err
}

return &Config{
StaticPath: getEnv("STATIC_PATH", filepath.Join(exPath, "..", "static")),
TemplatesPath: getEnv("TEMPLATES_PATH", filepath.Join(exPath, "..", "templates", "*")),
ServerAddr: getEnv("SERVER_ADDR", ":8080"),
DatabasePath: getEnv("DATABASE_PATH", "./nous.db"),
LLMBaseURL: getEnv("LLM_BASE_URL", "http://localhost:5000"),
RedisAddr: getEnv("REDIS_ADDR", "localhost:6379"),
}, nil
return &Config{
StaticPath: getEnv("STATIC_PATH", filepath.Join(exPath, "..", "static")),
ServerAddr: getEnv("SERVER_ADDR", ":8080"),
DatabasePath: getEnv("DATABASE_PATH", "./nous.db"),
LLMBaseURL: getEnv("LLM_BASE_URL", "http://localhost:5000"),
RedisAddr: getEnv("REDIS_ADDR", "localhost:6379"),
}, nil
}

// getExecutablePath returns the directory of the current executable
func getExecutablePath() (string, error) {
ex, err := os.Executable()
if err != nil {
return "", err
}
return filepath.Dir(ex), nil
ex, err := os.Executable()
if err != nil {
return "", err
}
return filepath.Dir(ex), nil
}

// getEnv retrieves the value of the environment variable named by the key
// If the variable is not present, it returns the fallback value
func getEnv(key, fallback string) string {
if value, exists := os.LookupEnv(key); exists {
return value
}
return fallback
if value, exists := os.LookupEnv(key); exists {
return value
}
return fallback
}
1 change: 0 additions & 1 deletion app/internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func (s *DefaultServer) SetupRoutes() {
s.router.Use(s.globalErrorHandler())

s.router.Static("/static", s.config.StaticPath)
s.router.LoadHTMLGlob(s.config.TemplatesPath)

chatStore := store.NewChatStore(s.db.GetDB())
chatAPIHandler := handlers.NewChatAPIHandler(chatStore, s.llmClient)
Expand Down
Loading

0 comments on commit 6efa8b6

Please sign in to comment.