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 7707961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:29:22+00:00 2026-06-01T00:29:22+00:00

I am currently working on a web-app/server in python and cherrypy. Right now, I

  • 0

I am currently working on a web-app/server in python and cherrypy.

Right now, I have been trying to create a kind of gallery page. For every photo, i have implemented for following HTML code:

<div> class="gallery" align="center">
  <div class="thumbnails">
    <img onmouseover="preview.src=img1.src" id="img1" src="../img/1" alt="Image Not Loaded"/>
    <img onmouseover="preview.src=img2.src" id="img2" src="../img/2" alt="Image Not Loaded"/>
  </div>
<br/>
  <div class="preview" align="center">
    <img id="preview" src="../img/1" alt="No Image Loaded"/>
    <img id="preview" src="../img/2" alt="No Image Loaded"/>
  </div>
</div>

It all works quite well, except that another method in my web app allows the user to add photos into the folder. (Or I could add photos into the folder manually sometimes). EDIT: [This folder is just a directory on my computer/server where all photo i want to be displayed in the gallery is stored.] This means that the number of photos in the folder is constantly changing.

I was wondering if there is some way for python to detect how many photo is in the folder, and dynamically and automatically add those photos into this HTML script?

EDIT[

I am thinking of changing my html script to:

<div> class="gallery" align="center">
  <div class="thumbnails">
   $$THUMB
  </div>
<br/>
  <div class="preview" align="center">
    $$PREVIEW
  </div>
</div>

Then implement some kind of loop in python that scans the entire folder for images. Followed by

page = page.replace ("$$THUMB", thumb)
page = page.replace ("$$PREVIEW", preview)

Where “thumb” and “preview” is the output of the loop that put every image i have in the folder into the proper HTML format.

Do you think that would work? And unfortunately, I have no idea how to get python to scan a folder for the name if files, then format it into the proper format. So this is probably where i need the most help.

]

Thank you for your time in advance!

  • 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-01T00:29:24+00:00Added an answer on June 1, 2026 at 12:29 am

    Usually with applications of this sort, the HTML file will be generated on the fly for every page view (and never stored on your server, just sent to the user). Since the contents change frequently this is definitely recommended. Start by getting a list of all files you would be serving with os.listdir or os.walk (if you must inspect nested directories). Then figure out how to present the list of files in your webpage.

    If you are asking how to detect changes during the time that a user has a browser page open, that’s a lot less straightforward. The browser needs to fetch an update from the server, so you’ll need some javascript that talks to a service on your website that checks the folder. The easiest would be for the service to compute something and send it to the javascript (e.g., last modification time, or an MD5 hash of the list of filenames). The user’s page can compare it with the last value and reload as necessary.

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

Sidebar

Related Questions

I'm currently working on web application using VB in ASP.NET. Right now I have
I'm currently working on building a java web app. I've been looking to use
I'm working on a project in Ruby right now that is essentially a web-app.
I am currently working on a web app using Wicket and started using jQuery
The ASP.NET web app project I'm currently working on is getting slower over time
I’m currently working on a small web app that allows people to search for
I am currently working on a JS menu for a web app. It consists
I currently started working on a maven web-app project that needs to be launched
I am currently working on a simple web application through Google App engine using
So, I'm working in a hybrid web app/mvc application. Trying to do all new

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.