#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2007
    Posts
    14
    Rep Power
    0

    Help needed with web app architecture


    Hi,

    I am working on a web app that acts a static content generator. Here is how it works:

    I have a set of HTML files. All the static content is stored in a database. For each piece of content in the database, I have a placeholder token in the HTML file. So whenever we want to generate the files HTML files, I want to call in the values from the database, replace the placeholders with the real text and then save the HTML files. The content from the database will be returned through a web service as JSON. So, I don't have to worry about the database connection part.

    My question is what is the best way to do this. Here is what I was thinking:

    1. Create all the HTML files with placeholders.
    2. Import the content of an HTML file as a string.
    3. Fetch the JSON with real values.
    4. Map the real values to the placeholders.
    5. Save the string back to the HTML file.

    Is this the best way to do this? Is there something that can be done here in a better way? Share your thoughts and suggestion about this architecture.

    Thanks,
    Leon
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    114
    Rep Power
    4
    A better way is to use a template engine such as Mako, which basically does all that stuff for you in a nicer way.

IMN logo majestic logo threadwatch logo seochat tools logo