Example #1
0
def index(_request):
    rsslist = []
    try:
        for rss in Rssurl.select(order_by='id'):
            rsslist.extend(parse_rss(rss.url))
    except:
        pass
    res = Response()
    p = path.join(path.dirname(__file__), 'rsslist.html')
    t = SimpleTemplate(file_path=p)
    body = t.render({'rsslist': rsslist})
    res.set_body(body)
    return res
Example #2
0
def index(_request):
    rsslist=[]
    try:
        for rss in Rssurl.select(order_by='id'):
            rsslist.extend(parse_rss(rss.url))
    except:
        pass
    
    res=Response()
    p=path.join(path.dirname(__file__), 'rsslist.html')
    t=SimpleTemplate(file_path=p)
    body=t.render({'rsslist':rsslist[:20]})
    res.set_body(body)
    return res
Example #3
0
cgitb.enable()

form_body = u"""
    <form method="post" action="/cgi-bin/rssreader1.py">
        RSSのURL:
        <input type="text" size="40" name="url" value="%s" />
        <input type="submit" />
    </form>"""

rss_parts = u"""
<h3><a href="%(link)s">%(title)s</a></h1>
<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
Example #4
0
#!/usr/bin/python
# coding: utf-8

from simpletemplate import SimpleTemplate
from rssurl import Rssurl
from os import path
from httphandler import Request, Response
from rssparser import parse_rss
import cgitb
cgitb.enable()

rsslist = []
try:
    # TODO: 実装
    for rss in Rssurl.select(order_by='id'):
        rsslist.extend(parse_rss(rss.url))
except:
    pass

res = Response()
p = path.join(path.dirname(__file__), 'rsslist.html')
t = SimpleTemplate(file_path=p)
body = t.render({'rsslist': rsslist[:20]})
res.set_body(body)

print res
Example #5
0
#!/usr/bin/env python
# coding: utf-8

from simpletemplate import SimpleTemplate
from rssurl import Rssurl
from os import path
from httphandler import Request, Response
from rssparser import parse_rss
import cgitb; cgitb.enable()

rsslist=[]
try:
    for rss in Rssurl.select(order_by='id'):
        rsslist.extend(parse_rss(rss.url))
except:
    pass

res=Response()
p=path.join(path.dirname(__file__), 'rsslist.html')
t=SimpleTemplate(file_path=p)
body=t.render({'rsslist':rsslist[:20]})
res.set_body(body)
print res

Example #6
0
import cgitb; cgitb.enable()

form_body=u"""
  <form method="POST" action="/cgi-bin/rssreader1.py">
    RSSのURL:
    <input type="text" size="40" name="url" value="%s"/>
    <input type="submit" />
  </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
Example #7
0
"""

sc=u"""
<div id="load%(id)d"></div>
<script type="text/javascript">
getPage("#load%(id)d","%(url)s");
</script>
"""

id=0 
dup=[]
content=u''
req = Request()
if req.form.has_key('url'):
    try:
        rss_list = parse_rss(urls[req.form['url'].value])
        for d in rss_list:
            if not d['link'] in dup:
                content += rss_parts % d
                dup.extend([d['link']])
                #外部リンク
                content+=sc%{'id':id,'url' : d['link']}
                id += 1   
                content += '<hr/>' 
 		 
    except:
        pass
 
res=Response()
body=form_body
body+=content
Example #8
0
from rssparser import parse_rss
from httphandler import Request, Response, get_htmltemplate
import cgitb; cgitb.enable()


form_body = """
<form method="POST" action="/cgi-bin/rssreader1.py">
  RSSのURL:
  <input type="text" size="40" name="url" value="%s" />
  <input type="submit" />
</form>"""
rss_parts = """
<h3><a href="%(link)s">%(title)s</a></h3>
<p>%(description)s</p>
"""

content = "URLを入力してください。"
req = Request()
u = req.form.getvalue('url', '')
if u != '':
    rss_list = parse_rss(u)
    content = ""
    for d in rss_list:
        content += rss_parts % d

res = Response()
body = form_body % u
body += content
res.set_body(get_htmltemplate() % body)
print(res)
Example #9
0
  RSSのURL:
  <input type="text" size="40" name="url" value="{0}"/>
  <input type="submit" />
</form>"""

rss_parts = """
<h3><a href="{0[link]}">{0[title]}</a></h3>
<p>{0[description]}</p>
"""

content = "URLを入力してください"

req = Request()
if "url" in req.form:
    try:
        rss_list = parse_rss(req.form["url"].value)
        content = ""
        for d in rss_list:
            content += rss_parts.format(d)
    except:
        pass


res = Response()
body = form_body.format(req.form.getvalue("url", ""))
body += content
res.set_body(get_htmltemplate().format(body))
print(res)
print("\r\n")