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.

49 lines
1.4 KiB

7 months ago
7 months ago
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. import config
  4. app = Flask(__name__)
  5. @app.errorhandler(404)
  6. def page_not_found(e):
  7. return render_template('error.html', title=config.TITLE, errorcode='404', style=config.STYLE), 404
  8. @app.route('/')
  9. @app.route('/index.html')
  10. def index():
  11. content = con_gen.gen_index_string()
  12. return render_template('index.html', title=config.TITLE, content_string=content, style=config.STYLE)
  13. @app.route('/archive')
  14. @app.route('/archive.html')
  15. def blog_archive():
  16. content = con_gen.gen_arch_string()
  17. return render_template('archive.html', title=config.TITLE, content_string=content, style=config.STYLE)
  18. @app.route('/entry/<path>')
  19. def entry(path):
  20. content = con_gen.gen_stand_string(path)
  21. if content != '':
  22. return render_template('standalone.html', title=config.TITLE, content_string=content, style=config.STYLE)
  23. abort(404)
  24. @app.route('/feed.xml')
  25. @app.route('/rss.xml')
  26. def feed():
  27. content = con_gen.get_rss_string()
  28. rss_xml = render_template('rss.xml', content_string=content, title=config.TITLE,
  29. description=config.DESCRIPTION, website=config.WEBSITE)
  30. response = make_response(rss_xml)
  31. response.headers['Content-Type'] = 'application/rss+xml'
  32. return response
  33. if __name__ == '__main__':
  34. app.run(host='0.0.0.0')