Created
January 23, 2012 06:49
-
-
Save FiNGAHOLiC/1661289 to your computer and use it in GitHub Desktop.
rssreader1.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env python | |
| # coding: urf-8 | |
| from rssparser import parse_rss | |
| from httphandler import Request, Response, get_htmltemplate | |
| import cgitb; cgitb.enable() | |
| form_body = u""" | |
| <form method="POST" action="/cgi-bin/rssreader1.py"> | |
| <p>RSSのURL <input type="text" size="40" name="url" value="%s"></p> | |
| <p><input type="submit"></p> | |
| </form>""" | |
| rss_parts = u""" | |
| <h3><a href="%(link)s">%(title)s</a></h3> | |
| <p>%(description)s</p> | |
| """ | |
| content = u"URLを入力してください" | |
| req = Request() | |
| if req.form.has_key('url'): | |
| try: | |
| rss_list = parse_rss(req.form['url'].value) | |
| content = "" | |
| for d in rss_list: | |
| content += rss_parts % d | |
| except: | |
| pass | |
| res = Response() | |
| body = form_body % req.form.getvalue('url', '') | |
| body += content | |
| res.set_body(get_htmltemplate() % body) | |
| print res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment