-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from g-linville/more-examples
Add a couple examples
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
tools: sys.find, sys.read, sys.write, sys.exec | ||
|
||
I have a new tool called gptscript. You can find information about it here in this folder | ||
by looking at *.gpt files and the README.md file. The examples folder should be particularly helpful. | ||
|
||
Do the following: | ||
|
||
1. Search through the *.gpt files and README.md in order to learn how gptscript works. | ||
2. Write a new gptscript file called myfile.gpt that uses the sys.write tool to write the first 10 | ||
numbers in the Fibonacci sequence to a file called fibonacci.txt. | ||
3. Execute the myfile.gpt script by running the following command: gptscript myfile.gpt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
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 | ||
|
||
docker run -d -p 27017:27017 --name mongodb mongo:latest | ||
|
||
--- | ||
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} |