Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 874725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:09:03+00:00 2026-05-15T11:09:03+00:00

I have a web-app consisting of some html forms for maintaining some tables (SQlite,

  • 0

I have a web-app consisting of some html forms for maintaining some tables (SQlite, with CherryPy for web-server stuff). First I did it entirely ‘the Python way’, and generated html strings via. code, with common headers, footers, etc. defined as functions in a separate module.

I also like the idea of templates, so I tried Jinja2, which I find quite developer-friendly. In the beginning I thought templates were the way to go, but that was when pages were simple. Once .css and .js files were introduced (not necessarily in the same folder as the .html files), and an ever-increasing number of {{…}} variables and {%…%} commands were introduced, things started getting messy at design-time, even though they looked great at run-time. Things got even more difficult when I needed additional javascript in the or sections.

As far as I can see, the main advantages of using templates are:
Non-dynamic elements of page can easily be viewed in browser during design.
Except for {} placeholders, html is kept separate from python code.
If your company has a web-page designer, they can still design without knowing Python.

while some disadvantages are:
{{}} delimiters visible when viewed at design-time in browser
Associated .css and .js files have to be in same folder to see effects in browser at design-time.
Data, variables, lists, etc., must be prepared in advanced and either declared globally or passed as parameters to render() function.

So – when to use ‘hard-coded’ HTML, and when to use templates? I am not sure of the best way to go, so I would be interested to hear other developers’ views.

TIA, Alan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T11:09:04+00:00Added an answer on May 15, 2026 at 11:09 am

    The simplest way to solve your static file problem is to use relative paths when referring to them in your html. For example: <img src="static/image.jpg" />

    If you’re willing to put in a little more work, you can solve all the design-time problems you mentioned by writing a mini-server to display your templates.

    1. Maintain a file full of simple data structures containing example values for all your templates.
    2. Use a microframework like Werkzeug to serve http on your local machine.
    3. Write a root request handler that scans your data structure list or templates directory to produce an index page with links to all your templates.
    4. Write a secondary request handler for non-root requests, which renders the requested template with the data structure of the same name.

    You can write this tool in a few hours, and it makes template design very convenient. One nice feature of Werkzeug’s built-in wsgi server is that it can automatically reload itself when it detects that a file has changed. You can leave your mini-server running while you edit templates and click links on your index page all day.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web app consisting of some JSPs that were previously running on
I have a JavaEE6 application, consisting of Web stuff and EJBs and which is
This is my first test for Asp.Net Web Application. We have an Engine consisting
need ask you about some help. I have web app running in Net 2.0.
I have a web-app with a Java back-end that uses Tomcat jdbc-pool for database
I have a web app that runs fine in Visual web developer. But when
I have a web app built with Dojo 1.7.2, using RequireJS to load individual
I have another web app, that uses the liferay user database. But before a
I have a web app. I am using JSF2 framework. My problem started when
I have a web app, where I keep a subdomain for every client eg:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.