On Thu, Oct 17, 2013 at 7:28 PM, Mark Siegrist <[email protected]> wrote:
> I'm a beginner at web2py, webapps, and Python in general and am having
> trouble and was hoping I could get some guidance here.
>
> I'm looking to have a page in my app that simply displays a simple list of
> RSS feeds. I eventually want to make something more robust but this is the
> key starting thing I need to learn how to do.
>
> My app contains these files:
>
> controllers/default.py
> views/reddit.py (I'm just using Reddit for now because of the readily
> available RSS feed)
>
> *default.py control code:*
>
> import feedparser
> def reddit():
> d = feedparser.parse('http://www.reddit.com/r/python/.rss')
> content_feed = []
> content_entry = []
> for feed in d:
> #print post.title + ": " + post.link + "\n"
> content_feed.append(feed.title)
>
> return dict(content=content_feed)
>
>
> *reddit.html view code:*
>
> {{extend 'layout.html'}}
> <h1>Latest Reddit Feeds</h1>
> <ul>
> {{for feed in content:}}
> {{=LI(feed)}}
> {{pass}}
> </ul>
>
>
Maybe something like this, if I recall correctly.
(note: not tested)
controller:
import feedparser
def reddit():
d = feedparser.parse('http://www.reddit.com/r/python/.rss')
return dict(content=d.entries)
view:
{{extend 'layout.html'}}
<h1>Latest Reddit Feeds</h1>
<ul>
{{for feed in content:}}
{{=LI(feed.title)}}
{{pass}}
</ul>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.