app.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. from flask import Flask, render_template
  2. from PostRenderer import PostRenderer
  3. import os
  4. app = Flask(__name__)
  5. post_renderer = PostRenderer()
  6. current_file_directory = os.path.dirname(__file__)
  7. def static_file_path(relative_path):
  8. return os.path.join(current_file_directory, relative_path)
  9. @app.route('/')
  10. @app.route('/index')
  11. @app.route('/home')
  12. def index():
  13. complete_html_content = post_renderer.render_posts_from(
  14. static_file_path('static/markdown/home/')
  15. )
  16. return render_template('index.j2', title='Zelphir\'s Blog', content=complete_html_content)
  17. @app.route('/lf2/blog')
  18. def lf2_blog():
  19. complete_html_content = post_renderer.render_posts_from(
  20. static_file_path('static/markdown/lf2/blog/')
  21. )
  22. return render_template(
  23. 'lf2_blog.j2', title='LF2 Blog', content=complete_html_content
  24. )
  25. @app.route('/lf2/intro')
  26. def lf2_intro():
  27. complete_html_content = post_renderer.render_posts_from(
  28. static_file_path('static/markdown/lf2/intro/')
  29. )
  30. return render_template(
  31. 'lf2_blog.j2', title='Little Fighter 2', content=complete_html_content
  32. )
  33. @app.route('/lf2/tools')
  34. def lf2_tools():
  35. complete_html_content = post_renderer.render_posts_from(
  36. static_file_path('static/markdown/lf2/tools/')
  37. )
  38. return render_template(
  39. 'lf2_blog.j2', title='Little Fighter 2 Tools', content=complete_html_content
  40. )
  41. @app.route('/lf2/recordings')
  42. def lf2_recordings():
  43. complete_html_content = post_renderer.render_posts_from(
  44. static_file_path('static/markdown/lf2/recordings/')
  45. )
  46. return render_template(
  47. 'lf2_blog.j2', title='Little Fighter 2 Recordings', content=complete_html_content
  48. )
  49. @app.route('/lf2/resources')
  50. def lf2_resources():
  51. complete_html_content = post_renderer.render_posts_from(
  52. static_file_path('static/markdown/lf2/resources/')
  53. )
  54. return render_template(
  55. 'lf2_blog.j2', title='Little Fighter 2 Resources', content=complete_html_content
  56. )
  57. @app.route('/chinese/blog')
  58. def chinese_blog():
  59. complete_html_content = post_renderer.render_posts_from(
  60. static_file_path('static/markdown/chinese/blog/')
  61. )
  62. return render_template(
  63. 'chinese_blog.j2', title='Chinese Blog', content=complete_html_content
  64. )
  65. @app.route('/chinese/hanzi')
  66. def chinese_hanzi():
  67. complete_html_content = post_renderer.render_posts_from(
  68. static_file_path('static/markdown/chinese/hanzi/')
  69. )
  70. return render_template(
  71. 'chinese_hanzi.j2', title='Hanzi', content=complete_html_content
  72. )
  73. @app.route('/coding/blog')
  74. def coding_blog():
  75. complete_html_content = post_renderer.render_posts_from(
  76. static_file_path('static/markdown/coding/blog/')
  77. )
  78. return render_template(
  79. 'coding_blog.j2', title='Coding Blog', content=complete_html_content
  80. )
  81. @app.route('/coding/resources')
  82. def coding_resources():
  83. complete_html_content = post_renderer.render_posts_from(
  84. static_file_path('static/markdown/coding/resources/')
  85. )
  86. return render_template(
  87. 'coding_blog.j2', title='Coding Blog', content=complete_html_content
  88. )
  89. @app.route('/about')
  90. def about():
  91. complete_html_content = post_renderer.render_posts_from(
  92. static_file_path('static/markdown/about/')
  93. )
  94. return render_template(
  95. 'about.j2', title='About', content=complete_html_content
  96. )
  97. if __name__ == '__main__':
  98. app.run(debug=True)