params
This commit is contained in:
@@ -9,6 +9,7 @@ ai 繪圖服務端(快速重構)
|
|||||||
- [ ] /api/tasks [#任務詳情](#任務列表)
|
- [ ] /api/tasks [#任務詳情](#任務列表)
|
||||||
- [ ] /api/models [#模型列表](#模型列表)
|
- [ ] /api/models [#模型列表](#模型列表)
|
||||||
- [ ] /api/images [#圖片列表](#圖片列表)
|
- [ ] /api/images [#圖片列表](#圖片列表)
|
||||||
|
- [ ] /api/params [#參數列表](#參數列表)
|
||||||
|
|
||||||
列表接口-請求方式
|
列表接口-請求方式
|
||||||
Method | URL | Info
|
Method | URL | Info
|
||||||
@@ -29,6 +30,7 @@ POST | /api/{name} | 篩選:創建新對象
|
|||||||
- [ ] /api/tasks/{task_id} [#任務詳情](#任務詳情)
|
- [ ] /api/tasks/{task_id} [#任務詳情](#任務詳情)
|
||||||
- [ ] /api/models/{model_id} [#模型詳情](#模型詳情)
|
- [ ] /api/models/{model_id} [#模型詳情](#模型詳情)
|
||||||
- [ ] /api/images/{image_id} [#圖片詳情](#圖片詳情)
|
- [ ] /api/images/{image_id} [#圖片詳情](#圖片詳情)
|
||||||
|
- [ ] /api/params/{params_id} [#參數詳情](#參數詳情)
|
||||||
|
|
||||||
詳情接口-請求方式:
|
詳情接口-請求方式:
|
||||||
Method | URL | Info
|
Method | URL | Info
|
||||||
@@ -42,7 +44,6 @@ WS | /api/{name}/{item_id} | Websocket 連接對象
|
|||||||
* GET查詢以外的操作都必須在headers中攜帶token驗證身份權限
|
* GET查詢以外的操作都必須在headers中攜帶token驗證身份權限
|
||||||
* GET查詢私有模型也必須登錄, 否則不會被展示
|
* GET查詢私有模型也必須登錄, 否則不會被展示
|
||||||
|
|
||||||
|
|
||||||
對象模型:
|
對象模型:
|
||||||
```go
|
```go
|
||||||
type ListView struct {
|
type ListView struct {
|
||||||
@@ -111,6 +112,9 @@ type User struct {
|
|||||||
CreatedAt string `json:"created_at"`
|
CreatedAt string `json:"created_at"`
|
||||||
UpdatedAt string `json:"updated_at"`
|
UpdatedAt string `json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Param struct {
|
||||||
|
}
|
||||||
```
|
```
|
||||||
```javascript
|
```javascript
|
||||||
//// TODO
|
//// TODO
|
||||||
|
13
main.go
13
main.go
@@ -44,10 +44,21 @@ func main() {
|
|||||||
r.HandleFunc("/api/tasks/{id}", tasks_item_patch).Methods("PATCH")
|
r.HandleFunc("/api/tasks/{id}", tasks_item_patch).Methods("PATCH")
|
||||||
r.HandleFunc("/api/tasks/{id}", tasks_item_delete).Methods("DELETE")
|
r.HandleFunc("/api/tasks/{id}", tasks_item_delete).Methods("DELETE")
|
||||||
|
|
||||||
|
r.HandleFunc("/api/params/model", models_params_get).Methods("GET")
|
||||||
|
|
||||||
log.Println("Web Server is running on http://localhost:8080")
|
log.Println("Web Server is running on http://localhost:8080")
|
||||||
http.ListenAndServe(":8080", r)
|
http.ListenAndServe(":8080", r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func models_params_get(w http.ResponseWriter, r *http.Request) {
|
||||||
|
params := make(map[string]interface{})
|
||||||
|
params["type"] = []string{"lora", "ckp", "hyper", "ti"}
|
||||||
|
params["status"] = []string{"pending", "running", "finished", "failed"}
|
||||||
|
params["base_model"] = []string{"SD1.5", "SD2"}
|
||||||
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
|
w.Write(ToJSON(params))
|
||||||
|
}
|
||||||
|
|
||||||
func models_get(w http.ResponseWriter, r *http.Request) {
|
func models_get(w http.ResponseWriter, r *http.Request) {
|
||||||
var listview models.ListView
|
var listview models.ListView
|
||||||
listview.Page = ParamInt(r.URL.Query().Get("page"), 1)
|
listview.Page = ParamInt(r.URL.Query().Get("page"), 1)
|
||||||
@@ -154,7 +165,7 @@ func images_get(w http.ResponseWriter, r *http.Request) {
|
|||||||
listview.Total = models.CountImages()
|
listview.Total = models.CountImages()
|
||||||
listview.Next = listview.Page*listview.PageSize < listview.Total
|
listview.Next = listview.Page*listview.PageSize < listview.Total
|
||||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
w.Write(ToJSON(listview))
|
w.Write(listview.ToJSON())
|
||||||
}
|
}
|
||||||
|
|
||||||
func images_post(w http.ResponseWriter, r *http.Request) {
|
func images_post(w http.ResponseWriter, r *http.Request) {
|
||||||
|
Reference in New Issue
Block a user