In this tutorial series we create RestAPI in Nim using HappyX web framework ✌
Getting Started 🔨
At first we need to install Nim lang
After this via nimble
we install HappyX
🔌
nimble install happyx@#head
I will edit my code with VS Code ✌
Project Creation 🛠
Just run this command
hpx create --name:tutorial --kind:SSG
cd tutorial/src
Hello, world! ✌
Let's open tutorial/src/main.nim
You'll see this (without comments)
import
# This will import HappyX framework
happyx
# Setting up our server at `127.0.0.1:5000`
serve("127.0.0.1", 5000):
# on GET HTTP method at 127.0.0.1:5000/
get "/":
# We'll see "Hello, world!"
"Hello, world!"
Let's rename route
# on GET HTTP method at 127.0.0.1:5000/hello-world
get "/hello-world":
Now let's try it 🎈
nim c -r -d:debug main
Open browser and go to http://localhost:5000/hello-world
🥳
Top comments (0)