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.

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