Eclectic Media Git eclecticmedia.space / master app.py
master

Tree @master (Download .tar.gz)

app.py @masterraw · history · blame

import os
from flask import Flask, abort, Response

from utilities import sort_blog
from utilities.renderer import render, render_markdown

app = Flask(__name__)


@app.route('/', methods=['GET'])
def index():
    return render('index.jinja',
                  context={'about_us': render_markdown('content/about-us.md'),
                           # 'blog':
                           # [item for item in sort_blog()],
                           # 'testimonial':
                           # render_markdown('content/testimonial.md')
                           'top_content': render_markdown('content/top-content.md'),
                           }
                  )


# @app.route('/blog/', methods=['GET'])
# def blog():
#     return render('blog.jinja',
#                   context={'items': [item for item in sort_blog()]})


# @app.route('/blog/<path:article>', methods=['GET'])
# def article(article):
#     article = f'content/blog/{article}.md'
#     if os.access(article, os.F_OK):
#         return render('widgets/content.jinja',
#                       context={'body':
#                                render_markdown(article)}
#                       )
#     else:
#         abort(404)


# @app.route('/rss/feed.xml', methods=['GET'])
# def feed():
#     def parse_description(path):
#         with open(path) as f:
#             text = f.read()
#
#         for line in text.split('\n'):
#             if len(line) > 0 and line[0].isalnum() and not line.count('&'):
#                 return line.strip('\n')
#
#     context = {'items': []}
#     for item in sort_blog():
#         context['items'].append(
#             {
#                 'title': item[0],
#                 'link': 'https://eclecticmedia.space/blog/{}'.format(item[1]),
#                 'description': parse_description(item[2]),
#             }
#         )
#
#     context['title'] = 'Eclectic Media Solutions Blog'
#     context['link'] = 'https://eclecticmedia.space/blog/'
#     context['description'] = 'Open source tech musings'
#
#     return Response(render('feed.xml', context=context),
#                     mimetype='text/xml')


if __name__ == '__main__':
    app.run()