我知道我可以像这样使用curl创建一个REST客户端
curl -o out.json http://www.example.com/index.html
有没有办法制作一个使用命令行发送 json 文件的 REST 服务器?
即服务器监听curl请求并响应json数据。
谢谢。
最佳答案
您可以考虑Python's SimpleHTTPServer可以使用 python -m SimpleHTTPServer [port]
运行,默认 http 端口为 80。您所需要做的就是在运行命令的目录中存储一个 JSON 文件,您可以使用 http://127.0.0.1/path/to/file.json
访问 JSON 文件的 url。 。或者,您可以检查 this post一种使用 netcat 制作简单 Web 服务器的方法。但是,curl 是客户端应用程序,不能用于创建 Web 服务器。
关于linux - Curl 作为 REST 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55938866/