Browse Source

2

tags/v1.21.7
lewis 5 years ago
parent
commit
21459fcb77
2 changed files with 21 additions and 3 deletions
  1. +17
    -1
      routers/repo/cloudbrain.go
  2. +4
    -2
      routers/routes/routes.go

+ 17
- 1
routers/repo/cloudbrain.go View File

@@ -2,8 +2,10 @@ package repo

import (
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/storage"
"encoding/json"
"errors"
"net/http"
"os"
"os/exec"
"strconv"
@@ -333,7 +335,7 @@ func CloudBrainDel(ctx *context.Context) {
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/cloudbrain")
}

func CloudBrainGetModels(ctx *context.Context) {
func CloudBrainShowModels(ctx *context.Context) {
ctx.Data["PageIsCloudBrain"] = true

var jobID = ctx.Params(":jobid")
@@ -344,6 +346,7 @@ func CloudBrainGetModels(ctx *context.Context) {
return
}

//get dirs


ctx.Data["task"] = task
@@ -351,6 +354,19 @@ func CloudBrainGetModels(ctx *context.Context) {
ctx.HTML(200, tplCloudBrainShowModels)
}

func CloudBrainDownloadModel(ctx *context.Context) {
filePath := ctx.Query("file_path")
fileName := ctx.Query("file_name")
url, err := storage.Attachments.PresignedGetURL(filePath, fileName)
if err != nil {
log.Error("PresignedGetURL failed: %v", err.Error())
ctx.ServerError("PresignedGetURL", err)
return
}

http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently)
}

func GetRate(ctx *context.Context) {
var jobID = ctx.Params(":jobid")
job, err := models.GetCloudbrainByJobID(jobID)


+ 4
- 2
routers/routes/routes.go View File

@@ -910,9 +910,11 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Post("/commit_image", reqRepoCloudBrainWriter, bindIgnErr(auth.CommitImageCloudBrainForm{}), repo.CloudBrainCommitImage)
m.Post("/stop", reqRepoCloudBrainWriter, repo.CloudBrainStop)
m.Post("/del", reqRepoCloudBrainWriter, repo.CloudBrainDel)
m.Get("/rate", reqRepoCloudBrainWriter, repo.GetRate)
m.Get("/rate", reqRepoCloudBrainReader, repo.GetRate)
m.Get("/models", reqRepoCloudBrainReader, repo.CloudBrainShowModels)
m.Get("/download_model", reqRepoCloudBrainReader, repo.CloudBrainDownloadModel)
})
m.Get("/create", reqRepoCloudBrainWriter, repo.CloudBrainNew)
m.Get("/create", reqRepoCloudBrainReader, repo.CloudBrainNew)
m.Post("/create", reqRepoCloudBrainWriter, bindIgnErr(auth.CreateCloudBrainForm{}), repo.CloudBrainCreate)
}, context.RepoRef())



Loading…
Cancel
Save