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

  • Home
  • SEARCH
  • 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 8329523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:49:10+00:00 2026-06-09T01:49:10+00:00

I’m having an issues with bottle python where I have the following code import

  • 0

I’m having an issues with bottle python where I have the following code

import glob
import os
from bottle import run, route, error, template
from Find_Posts import hyperlink_postnames

currentdir = os.getcwd()

def hyperlink_postnames():
    hyperlink_filelist = []
    os.chdir(currentdir + "\\Blog_Posts\\")

    for files in glob.glob("*.txt"):
        hyperlink_filelist.append('<a href = "/blog/' + files + '"' + '>' + str(os.path.splitext(files)[0]) + '</a>')
    return  hyperlink_filelist

which returns the following list

['<a href = "/blog/post1.txt">post1</a>', '<a href = "/blog/post2.txt">post2</a>', '<a href = "/blog/post3.txt">post3</a>', '<a href = "/blog/post4.txt">post4</a>', '<a href = "/blog/post5.txt">post5</a>', '<a href = "/blog/post6.txt">post6</a>']

which is in turn fed to the following bottlepy route:

@route('/blog/')
def postnames():
    postlist = hyperlink_postnames()
    tpl_out = template('blogroll', postlist = postlist)
    return  tpl_out

which is fed into the blogroll.tpl template:

<!DOCTYPE html>
<div>

<p><b>Blog Roll</b></p>

%for postlist in postlist:
    <li> {{ postlist }}
%end

</div>

my problem is when I render the template in the browser it turns the postlist variable in the template into plain text and not html (which is what’s written inside the list), However if I change the bottle code to read like this (bypassing the template) it renders the postlist variable as html but not inside the template which makes the code useless:

@route('/blog/')
def postnames():
    postlist = hyperlink_postnames()
    tpl_out = template('blogroll', postlist = postlist)
    return  postlist #return the variable directly bypassing the template renders the list as html

does anyone have any ideas as to why this happening?

  • 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-06-09T01:49:12+00:00Added an answer on June 9, 2026 at 1:49 am

    HTML special characters are escaped automatically to prevent XSS attacks.

    Use an exclamation mark at the start of your template statement to indicate that you really want to include HTML:

    %for postlist in postlist:
        <li> {{ !postlist }}
    %end
    

    See the documentation on inline statements.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and

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.