Get started
Create the project
This tutorial builds words, a small app that counts the words of a text and ranks them. Four short pages take it from an empty folder to a published package.
- Create the project and write the code.
- Add a package from the registry.
- Test the code.
- Build and publish it.
You need the edge CLI. The Quickstart installs it.
Scaffold it
Run edge init with the name of the project.
edge init words$ edge init words
created words/
├─ index.html
├─ main.py
└─ edge.json
cd words && edge serveIt makes a folder with three files.
| File | What it holds |
|---|---|
main.py | The entry point, a script that prints one line |
edge.json | The manifest of the project |
index.html | A page that runs main.py in the browser |
The manifest starts with one field.
{
"edge": "0.9.4"
}The edge field is the lowest engine the project runs on, the version of the CLI that made it. An older CLI refuses to run the project. Nothing else resolves until you declare it.
Write the code
Open main.py and replace its line with the word counter. You can also run it here.
the 3 cat 2 mat 1
count_wordslowercases the text, splits it on whitespace and strips punctuation from each word.top_wordssorts the counts from high to low and breaks a tie in alphabetical order.- The
__main__block runs only whenmain.pyis the entry point. A test can import the two functions without printing anything.
Run it
From the words folder, run the script.
edge run main.pyIt prints the same three lines as the example above. To see it in a browser, run edge serve and open the address it prints. The page reloads on every change.