This tutorial shows how to make RSS feeds in Python for Google App Engine.
This is actually really simple because I am using pre made library PyRSS2Gen.
Manual RSS Feeds(basic stuff to work):
Get the rss library and put PyRSS2Gen.py file in your project folder. I am using lib folder for all of my external libraries.Basic stuff to work:
This is my file structure:The init file in libs folder is necessary, otherwise the library won't work.Source code viewer
/ /controllers/rss.py /libs/__init__.py /libs/PyRSS2Gen.py /app.yamlProgramming Language: Text
This is my app.yaml file:
As you can see we will get our RSS code by going to http://your-project.appspot.com/rss.xml.Source code viewer
application: project-name version: 1 runtime: python api_version: 1 handlers: - url: /rss.xml script: controllers/rss.py - url: /static static_dir: staticProgramming Language: YAML
This is the RSS code generator, rss.py:
The simplest way to make this happen.Source code viewer
import datetime from libs import PyRSS2Gen rss = PyRSS2Gen.RSS2( title = "Test feed", link = "http://www.browse-tutorials.net/", description = "RSS Description", lastBuildDate = datetime.datetime.now(), items = [ PyRSS2Gen.RSSItem( title = "Feed 1", link = "http://www.browse-tutorials.net/tutorial/...", description = "RSS 1 Description", guid = PyRSS2Gen.Guid("guid1"), pubDate = datetime.datetime(2010, 9, 6, 21, 31)), PyRSS2Gen.RSSItem( title = "Feed 2", link = "http://www.browse-tutorials.net/tutorial/..." "archive/2003/09/06/RSS.html", description = "RSS 1 Description", guid = PyRSS2Gen.Guid("guid2"), pubDate = datetime.datetime(2010, 9, 6, 21, 49)), ]) print 'Content-Type: text/xml' print rss.to_xml()Programming Language: Python
That's how you make RSS code in Google App Engine. This is really basic. Of course you can take the data from datastore and use foreach to populate the RSS array.