Skip to content

Instantly share code, notes, and snippets.

@vaibhavmule
Created October 10, 2018 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vaibhavmule/4e686a3d23fbae6fe6ac23f093a40354 to your computer and use it in GitHub Desktop.
Save vaibhavmule/4e686a3d23fbae6fe6ac23f093a40354 to your computer and use it in GitHub Desktop.
RSS Feed using Masonite Framework
<?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>
"""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})
@josephmancuso
Copy link

with 2.1 you can get rid of that http_prefix=None line. It's None by default in 2.1+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment