Python - automatic webpage creation

Reply

Join Date: Sep 2009
Posts: 3
Reputation: furblender is an unknown quantity at this point 
Solved Threads: 0
furblender furblender is offline Offline
Newbie Poster

Python - automatic webpage creation

 
0
  #1
Sep 16th, 2009
Hi,
I have a minor website that I wish to maintain that I do for gratis (for free). It is for a school. I wish to be able to automate the task of adding links and photos and text body. I already use a css template to maintain the look and feel of the site but would like to go that one step closer to adding automation. I have the concept but do not know how to go from concept to actually programming what I would like to do with python. I have written very basic python and perl code.
I need direction.
Here are my thoughts at what I wish to achieve.

I have already created the basic folder structure for easy of keeping things clean and orderly.
Name of folder - within that -pdf folder - image folder - doc folder.
What I wish to be able to do is have files within these folders. That can be read by a python script.
Firstly to create links to documents or pdfs or photos secondly to grab the text body out of a text file and place it into the html document. Sounds easy. Well I have popped a blood vessel and would like some advise. I know that there are cms systems out there that could do this but the site on which this webpage site is housed will not allow for this interaction. Any suggestions.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 101
Reputation: ingeva is an unknown quantity at this point 
Solved Threads: 9
ingeva ingeva is offline Offline
Junior Poster

Re: Python - automatic webpage creation

 
0
  #2
Sep 16th, 2009
Originally Posted by furblender View Post
Hi,
Name of folder - within that -pdf folder - image folder - doc folder.
What I wish to be able to do is have files within these folders. That can be read by a python script.
I don't know python or perl, but in php including a text file is easy:
include <name of text file>;

In one of my sites I let the script search directories and display the filenames of that directory. The user can select which one he wants to see or download.
By adding new directories, even in several levels, it's possible to add nearly anything dynamically, with no code changes.
Yes, I'm running Ubuntu. Of course.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 403
Reputation: leegeorg07 is an unknown quantity at this point 
Solved Threads: 31
leegeorg07's Avatar
leegeorg07 leegeorg07 is offline Offline
Posting Pro in Training

Re: Python - automatic webpage creation

 
0
  #3
Sep 16th, 2009
in python you could use the open method, to write a basic framework you could write:
  1. new_page = open("name.html", "w")#change 'name' to whatever you want/input and you could use "a" to add to the page
  2. framework = """
  3. <html>
  4. <head><title>basic framework</title></head>#add in any extra
  5. <body>
  6. <p>
  7. This is some text
  8. </p>
  9. </body>
  10. </html>
  11. """
  12. new_page.write(framework)
You would need to use different inputs and editors for extras, but the admins should really move this to the python forum.
don't judge me because I'm a year 8!

'it is better to fight for something than to live for nothing'General George S Patton
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



Tag cloud for HTML and CSS
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC