forked from prakharcode/Blogit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
37 lines (32 loc) · 994 Bytes
/
main.py
File metadata and controls
37 lines (32 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from app import app,db
import admin
from models import *
import views
from flask import url_for, request
from werkzeug.contrib.atom import AtomFeed
from urlparse import urljoin
from entries.blueprint import entries
app.register_blueprint(entries, url_prefix = '/entries')
@app.route('/latest.atom')
def recent_feed():
feed = AtomFeed(
'Latest Blog Post',
feed_url = request.url,
url = request.url_root,
author = request.url_root
)
entries = Entry.query.filter(Entry.status == Entry.public).order_by(Entry.created_timestamp).limit(15).all()
for entry in entries:
feed.add(
entry.title,
entry.body,
author= entry.author,
content_type='html',
id = entry.id,
url = urljoin(request.url_root,url_for('entries.detail', slug = entry.slug)),
updated = entry.modified_timestamp,
published = entry.created_timestamp
)
return feed.get_response()
if __name__=='__main__':
app.run()