Traves commited on
Commit
aa0e8f8
·
verified ·
1 Parent(s): 21ae364

Add root handler to fix 404

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. cmd/server/main.go +10 -0
README.md CHANGED
@@ -17,6 +17,7 @@ This Space hosts a Go-based inference server for the **MicroGPT** model, providi
17
 
18
  - **`POST /v1/chat/completions`**: standard OpenAI chat format.
19
  - **`GET /v1/models`**: returns model metadata.
 
20
 
21
  ## Local Test
22
 
@@ -32,5 +33,4 @@ curl -X POST http://localhost:7860/v1/chat/completions \
32
  ```
33
 
34
  ## Repository
35
-
36
  Built with [MicroGPT Go Edition](https://github.com/Traves-Theberge/microgpt-tui-go).
 
17
 
18
  - **`POST /v1/chat/completions`**: standard OpenAI chat format.
19
  - **`GET /v1/models`**: returns model metadata.
20
+ - **`GET /`**: health check and status page.
21
 
22
  ## Local Test
23
 
 
33
  ```
34
 
35
  ## Repository
 
36
  Built with [MicroGPT Go Edition](https://github.com/Traves-Theberge/microgpt-tui-go).
cmd/server/main.go CHANGED
@@ -232,9 +232,19 @@ func handleModels(w http.ResponseWriter, r *http.Request) {
232
  json.NewEncoder(w).Encode(resp)
233
  }
234
 
 
 
 
 
 
 
 
 
 
235
  func main() {
236
  initModel()
237
 
 
238
  http.HandleFunc("/v1/chat/completions", handleChat)
239
  http.HandleFunc("/v1/models", handleModels)
240
 
 
232
  json.NewEncoder(w).Encode(resp)
233
  }
234
 
235
+ func handleRoot(w http.ResponseWriter, r *http.Request) {
236
+ if r.URL.Path != "/" {
237
+ http.NotFound(w, r)
238
+ return
239
+ }
240
+ w.Header().Set("Content-Type", "text/plain")
241
+ fmt.Fprintf(w, "MicroGPT API is running.\n\nEndpoints:\n- POST /v1/chat/completions\n- GET /v1/models\n")
242
+ }
243
+
244
  func main() {
245
  initModel()
246
 
247
+ http.HandleFunc("/", handleRoot)
248
  http.HandleFunc("/v1/chat/completions", handleChat)
249
  http.HandleFunc("/v1/models", handleModels)
250