DENO: Create your first server
I won’t be talking about what is deno here, rather I will explain the code to create a simple local server. To learn more about deno follow their official page.
Github repo on deno-project
For windows run the following command from your PowerShell ISE
iwr https://deno.land/x/install/install.ps1 -useb | iex
For other platforms, please follow this link here
To test if deno has installed successfully, run the
deno in the console.
You should see something like this.
Now we’re ready to write code.
A HelloWorld with deno
This is a simple code which prints
Hello World in the console.
To run this, run the following command
deno run helloWorld.ts
Creating a server with deno
The above code creates a server at
localhost:8000 for us.
Running the following command will give an error:
deno run server.ts
As we can see the logs, it's throwing an error saying we don’t have access to
In this case, we have to explicitly grant permission to access the local network.
deno run --allow-net=0.0.0.0:8000 server.ts
Now when we go to
localhost:8000 in the browser, we will be able to see
hello world being printed there.
We have successfully created our first server with DENO.
I hope you found this article useful. I would love to hear your thoughts. 😇
Thanks for reading. 😊
If you find this article useful, you can show your appreciation by clicking on the clap button. As the saying goes, ‘When we give cheerfully and accept gratefully, everyone is blessed’.