Created
October 10, 2018 11:40
-
-
Save vaibhavmule/4e686a3d23fbae6fe6ac23f093a40354 to your computer and use it in GitHub Desktop.
RSS Feed using Masonite Framework
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<rss version="2.0"> | |
<channel> | |
<title>CSClub Blog</title> | |
<description>Stay updated about Company Secretary"</description> | |
<link>http://csclub.co/blog/</link> | |
{% for post in posts %} | |
<item> | |
<title> | |
<![CDATA[{{ post.title }}]]> | |
</title> | |
<link>http://csclub.co/{{post.author.username}}/{{post.slug}}</link> | |
<description> | |
<![CDATA[{{ post.text }}]]> | |
</description> | |
<pubDate>{{post.published_date}}</pubDate> | |
<guid isPermaLink="true">http://csclub.co/{{post.author.username}}/{{post.slug}}</guid> | |
</item> | |
{% endfor %} | |
</channel> | |
</rss> |
This file contains 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
"""A FeedController Module""" | |
from masonite.view import View | |
from masonite.request import Request | |
from app.Post import Post | |
class FeedController: | |
"""FeedController | |
""" | |
def blog(self, view: View, request: Request): | |
posts = Post.all() | |
request.header('Content-Type', 'application/xml', http_prefix=None) | |
return view.render('feed/blog.xml', {'posts': posts}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
with 2.1 you can get rid of that
http_prefix=None
line. It'sNone
by default in 2.1+