Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not working with custom client (the new function) #1

Open
jackrankin opened this issue Jun 15, 2024 · 1 comment
Open

not working with custom client (the new function) #1

jackrankin opened this issue Jun 15, 2024 · 1 comment

Comments

@jackrankin
Copy link

jackrankin commented Jun 15, 2024

This is basically the default code except I swapped in my own locally hosted Piston API. I get this error message: 2024/06/14 22:14:32 Unexpected Error. {"message":"requests must be of type application/json"}


import (
	"fmt"
	"log"
	"net/http"

	piston "github.com/milindmadhukar/go-piston"
)

func runCode() {
	h := http.DefaultClient
	client := piston.New("", h, "http://127.0.0.1:2000/api/v2/")

	execution, err := client.Execute("python", "",
		[]piston.Code{
			{Content: "inp = input()\nprint(inp[::-1])"},
		},
		piston.Stdin("hello world"),
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(execution.GetOutput())
}

func main() {
	runCode()
}
```c
@milindmadhukar
Copy link
Owner

Could be a missing header when making the request. Made a quick fix, can you test and let me know?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants