Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

FROM python:3.12.3-alpine

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

WORKDIR /app

COPY . /app/
COPY requirements.txt /app/

RUN pip install --upgrade pip
RUN pip install -r /app/requirements.txt

COPY ./entrypoint.sh /app/
RUN chmod +x /app/entrypoint.sh

ENTRYPOINT ["/app/entrypoint.sh"]
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,43 @@ for product in products:
print(f"Tagline: {product['Tagline']}")
```



## Run it on Docker
- You can also clone the project and run it with docker exposing the function calls implemented as REST API endpoints. To do that follow these commands:

```
git clone https://github.com/dariubs/producthunt.py.git

```

- Add your API token that you get from ProductHunt
```
cd producthunt.py

open a file server.py then add it => api_key = 'product-hunt-token'

```

- Then build and run your docker container

```
cd producthunt.py

docker-compose up --build

```

- It will build and run the container on `http://localhost:8000`. Endpoints are named based on the current implemented funtions:

```
/get-daily
/product-details
/get-posts-by-topic

```


## License

This project is licensed under the terms of the MIT license.
Expand Down
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3'

services:
producthunt:
build:
context: .
dockerfile: Dockerfile
container_name: producthunt
ports:
- "8000:8000"
volumes:
- .:/app
restart: unless-stopped

3 changes: 3 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

python3 server.py
16 changes: 16 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
aniso8601==9.0.1
blinker==1.8.1
certifi==2024.2.2
charset-normalizer==3.3.2
click==8.1.7
Flask==3.0.3
graphene==3.3
graphql-core==3.2.3
graphql-relay==3.2.0
idna==3.7
itsdangerous==2.2.0
Jinja2==3.1.3
MarkupSafe==2.1.5
requests==2.31.0
urllib3==2.2.1
Werkzeug==3.0.2
28 changes: 28 additions & 0 deletions server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from flask import Flask
from flask import jsonify
from producthunt import ProductHunt

api_key = 'product-hunt-token'
ph = ProductHunt(api_key)
app = Flask(__name__)


@app.route('/product-details')
def get_product_details():
data = ph.get_product_details(slug='product')
return jsonify(data)

@app.route('/get-daily')
def get_daily():
data = ph.get_daily()
return jsonify(data)

@app.route('/get-posts-by-topic')
def get_posts_by_topic():
data = ph.get_posts_by_topic()
return jsonify(data)



if __name__ == '__main__':
app.run(host='0.0.0.0', port=8000, debug=True)