0

I know that I can make a REST client using curl like this

curl -o out.json http://www.example.com/index.html

Is there a way to make a rest server that send a json file using command line?

i.e. a server listening to curl requests and respond with a json data.

Thanks.

Roger World
  • 167
  • 2
  • 10
  • 1
    curl is a client-side application to make requests, it only listens for the response to its own request. – Dave S May 01 '19 at 16:04

1 Answers1

1

You could consider Python's SimpleHTTPServer that can be run with python -m SimpleHTTPServer [port], with default http being port 80. All you need to do is store a JSON file in the directory where you run the command, and you can access the url to the JSON file with http://127.0.0.1/path/to/file.json. Alternatively, you could check this post for a method to make a simple web server with netcat. However, curl is a client-side application and can't be used to create a web server.

Aplet123
  • 33,825
  • 1
  • 29
  • 55