A blog system based on plain-files.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
983 B

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
  1. from flask import Flask, flash, make_response, render_template, request, redirect
  2. import content as con_gen
  3. app = Flask(__name__)
  4. @app.errorhandler(404)
  5. def page_not_found(e):
  6. return render_template('error.html', title='Error 404', errorcode='404'), 404
  7. @app.route('/')
  8. @app.route('/index.html')
  9. def index():
  10. content = con_gen.gen_index_string()
  11. return render_template('index.html', title='Blog', content_string=content)
  12. @app.route('/archive')
  13. @app.route('/archive.html')
  14. def blog_archive():
  15. content = con_gen.gen_arch_string()
  16. return render_template('archive.html', title='Blog Archive', content_string=content)
  17. @app.route('/feed.xml')
  18. @app.route('/rss.xml')
  19. def feed():
  20. content = con_gen.get_rss_string()
  21. rss_xml = render_template('rss.xml', content_string=content)
  22. response = make_response(rss_xml)
  23. response.headers['Content-Type'] = 'application/rss+xml'
  24. return response
  25. if __name__ == '__main__':
  26. app.run(host='0.0.0.0')