How to create basic deno app

Deno is asynchronous JavaScript/TypeScript runtime. If you are not sure how and what’s of Deno, here is the links

Make a Deno server

With a single file and Oak dependency can create deno server app.

  • Create project folder
  • create a main.ts file
import { Application } from "";

const app = new Application();

app.use((ctx) => {
    ctx.response.body = "Hello World!";

app.listen({ port: 8000 });
console.log('Serveris running on port 8000')

In the first line we import the Application from the Oak module, which is used to create our basic site.

Using the use method we add middleware and running port for server using listen method of the Application object (app).

deno run maint.ts

While running the file, you may encounter Permission Denied: network access error. One of the feature of Deno is the way it handling the different permissions. You need to allow program whatever need to do, writing, reading, accessing network etc. Let’s run it again with necessary permissions

deno run --allow-net main.ts

Now jump into the browser access your route

Here our hello world route is a default route. What ever you type in route will get the same page. ( or )

To stop the running server use Ctrl+C

Published by


A developer,teacher and a blogger obsessed with Python,Dart and open source world from India

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.