Kronos1979
Kronos1979

Reputation: 21

How can I convert a HTML template into a Node.JS web app

I'm starting out on my Node.JS journey and I discovered a fantastic boilerplate over at https://github.com/azouaoui-med/pro-sidebar-template. I'm unsure though how to turn the static html into a web app. Just wondering how someone with more experience would do this?

Do I take the html and translate it into a PUG template file? I'm guessing to then make the onclick / links actually run some code, i'd need to point them at the routes setup in the web app?

Sorry to ask such inexperienced questions, web apps seem to take a vastly different approach to the desktop apps i'm familiar with programming

I'm wanting to create a web app that runs on a server, which I will later put on the desktop via electron.

thanks

Upvotes: 2

Views: 2766

Answers (1)

damitj07
damitj07

Reputation: 2919

The project you have is using browser-sync which indirectly uses NodeJS to run a local server and host the web application files.

Do I take the HTML and translate it into a PUG template file?

I am not sure about this question unless you specifically want to use server-side rendering I am not sure I would recommend this to start with especially if you plan to later convert this to a desktop application. [Note* - Assuming you are referencing this library PUGJS in statements above ]

Now For this requirement I'm wanting to create a web app that runs on a server, which I will later put on the desktop via electron.

This will require you to make your data serving layer which is most commonly called backend separate from that of the data viewing layer which is most commonly referred to as front-end. Thus a case for using the same data layer across different types of clients viz. A web application and/or A desktop application ( electron if you choose so )

Step 1 - Define what sort of web application architecture you want to follow or use. This will be based on your project and business requirements. From what information I have so far I would suggest a simple client-server architecture where your frontend or web-application is the client which makes REST API calls to the backend (API Server) and thus produces a meaningful result.

Step 2 - Start with the creation of 2 projects a frontend where your HTML, CSS JS, etc will be and a simple NodeJS script to serve this static web app when deployed on the server. I am going with NodeJS since the context of this question is suggesting the same.

Step 3 - The other project which will only be an API Server or Backend. This server will provide only REST API to the frontend. This server will talk to the database and provide other services like authentication and logging etc. You can use expressJS for this also in the frontend project.

Here is a simplistic representation of the client-server model which you can reference.

enter image description here

Some additional links for you to digest.

What is the difference between a web application and a client/server application?

https://medium.com/codiumclub/web-application-architecture-part-1-guide-to-become-full-stack-developer-cc9526a3519b

Upvotes: 2

Related Questions