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.

46 lines
1.2 KiB

7 months ago
7 months ago
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, abort
  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('/entry/<path>')
  18. def entry(path):
  19. content = con_gen.gen_stand_string(path)
  20. if content != '':
  21. return render_template('standalone.html', title='Blog Entry', content_string=content)
  22. abort(404)
  23. @app.route('/feed.xml')
  24. @app.route('/rss.xml')
  25. def feed():
  26. content = con_gen.get_rss_string()
  27. rss_xml = render_template('rss.xml', content_string=content)
  28. response = make_response(rss_xml)
  29. response.headers['Content-Type'] = 'application/rss+xml'
  30. return response
  31. if __name__ == '__main__':
  32. app.run(host='0.0.0.0')