forked from gptscript-ai/gptscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhacker-news-headlines.gpt
53 lines (40 loc) · 2.24 KB
/
hacker-news-headlines.gpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
tools: sys.http.get, sys.http.html2text, sys.find, sys.write, mongo_run, mongo_command, init_flask_project
Perform the following actions in this order:
1. Start the MongoDB database.
2. Create a collection in the Mongo instance called `headlines`.
3. Visit https://hackernews.com and get the top ten headlines.
4. Call the init_flask_project tool to set up the directories you will need.
5. Write each headline into the MongoDB collection that you created earlier called `headlines`. Write each one using a separate call to the mongo_command tool. The name of the database in Mongo that these will be written to is `headlines`. Don't forget to escape any quotation marks or apostrophes that appear in the headlines.
6. Generate a simple webserver in Python using Flask that will connect to the database and serve a single page listing all the headlines. Create it in the `headline` directory. Embed a link to the article in each headline displayed on the page.
7. Add some basic CSS styling to make the page look cool and modern. I want it to be dark themed. Style the links to be a light gray color. Make sure the page has a neat header with red accents.
---
name: mongo_run
description: starts a MongoDB database
#!/usr/bin/env bash
# The name of your container
CONTAINER_NAME=mongodb
# Check if the container already exists
if docker ps -a --format '{{.Names}}' | grep -Eq "^${CONTAINER_NAME}\$"; then
echo "Container ${CONTAINER_NAME} exists."
# Check if the container is already running
if ! docker ps --format '{{.Names}}' | grep -Eq "^${CONTAINER_NAME}\$"; then
echo "Starting existing container ${CONTAINER_NAME}."
docker start ${CONTAINER_NAME}
else
echo "Container ${CONTAINER_NAME} is already running."
fi
else
echo "Container ${CONTAINER_NAME} does not exist. Running a new one."
docker run --rm -d -p 27017:27017 --name ${CONTAINER_NAME} mongo:latest
fi
---
name: mongo_command
description: run a command in the MongoDB database
args: command: the command to run in mongodb
#!/usr/bin/env bash
mongosh mongodb://localhost:27017/headlines --eval "$COMMAND"
---
name: init_flask_project
description: sets up initial directory structure needed for the flask project
#!/usr/bin/env bash
mkdir -p headline/{templates,static}