HTTP Worker is a simple REST API built with Flask and cloudscraper that allows you to send HTTP requests to any URL.
- Docker
- Clone the repository:
git clone https://github.com/arifnd/http-worker.git
- Change into the project directory:
cd http-worker
- Build the Docker image:
docker build -t http-worker .
- Start the application using Docker:
docker run --rm -e SECRET_KEY=my-secret-key -e ALLOWED_IPS=127.0.0.1,192.168.1.1 -p 8080:8080 http-worker
Note: Replace my-secret-key
and 127.0.0.1,192.168.1.1
with your own values for the SECRET_KEY
and ALLOWED_IPS
environment variables.
This command will start a new Docker container. Once the tests are complete, the container will be automatically deleted.
You can use any HTTP client to send a POST request to the /request
endpoint with the url
parameter set to the URL you want to request.
For example, using curl
:
curl -X POST -H "X-Secret-Key: my-secret-key" http://localhost:8080/request -d "url=https://www.google.com"
You should receive a response with the HTTP status code and body of the response.
To run the unit tests, use the following command:
docker run --rm -e SECRET_KEY=my-secret-key -e ALLOWED_IPS=127.0.0.1,192.168.1.1 http-worker python -m unittest discover -s test
Note: Replace my-secret-key
and 127.0.0.1,192.168.1.1
with your own values for the SECRET_KEY
and ALLOWED_IPS
environment variables.
This command will start a new Docker container and run the tests inside it. Once the tests are complete, the container will be automatically deleted.
Contributions are welcome! Please feel free to submit a pull request or open an issue.
This project is licensed under the MIT License. See the LICENSE file for details.