--- /dev/null
+web: gunicorn -w 4 -b 0.0.0.0:$PORT -k gevent app:app
--- /dev/null
+import os
+from flask import Flask, render_template, request, redirect, url_for
+
+app = Flask(__name__)
+app.config['SECRET_KEY'] = os.environ['SECRET_KEY']
+
+###
+# Routing for your application.
+###
+
+@app.route('/')
+def home():
+ """Render website's home page."""
+ return render_template('index.html')
+
+
+###
+# The functions below should be applicable to all Flask apps.
+###
+
+@app.route('/<file_name>.txt')
+def send_text_file(file_name):
+ """Send your static text file."""
+ file_dot_text = file_name + '.txt'
+ return app.send_static_file(file_dot_text)
+
+
+@app.after_request
+def add_header(response):
+ """
+ Add headers to both force latest IE rendering engine or Chrome Frame,
+ and also to cache the rendered page for 10 minutes.
+ """
+ response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'
+ response.headers['Cache-Control'] = 'public, max-age=600'
+ return response
+
+
+@app.errorhandler(404)
+def page_not_found(error):
+ """Custom 404 page."""
+ return render_template('404.html'), 404
+
+
+if __name__ == '__main__':
+ app.run(debug=True)
+++ /dev/null
-#!/usr/bin/env python
-# a simple incremental build script.
-# usage build.py src_dir/ output_dir
-import os
-import sys
-import subprocess
-from os import listdir
-from os.path import isfile, join, getmtime
-
-
-def list_files(directory):
- return [f for f in listdir(directory)
- if isfile(join(directory, f))]
-
-def execute(command):
- return subprocess.call(command)
-
-def build_file(infile, outfile):
- print "Building {}".format(outfile)
-
- execute(['python', 'src/render_rfc.py', infile, outfile])
-
-def copy_static(out_dir):
- print "Copying static files."
- command = ['cp', '-r', 'static', out_dir]
- execute(command)
-
-def generate_site_index(out_dir):
- print "Creating index file."
- command = ['python', 'src/generate-site-index.py', out_dir, join(out_dir, 'index.html')]
- execute(command)
-
-def build_rfcs(src_dir, dest_dir):
- src_files = {filename: join(src_dir, filename) for filename in list_files(src_dir)}
- dest_files = {filename: join(dest_dir, filename) for filename in list_files(dest_dir)}
-
- for filename in src_files:
- src_path = join(src_dir, filename)
- dest_path = join(dest_dir, filename)
-
- if '.txt' in dest_path:
- dest_path = dest_path.split('.txt')[0] + '.html'
-
- if filename not in dest_files:
- build_file(src_path, dest_path)
-
- if os.path.exists(dest_path) and getmtime(src_path) > getmtime(dest_path):
- build_file(src_path, dest_path)
-
-
-def main():
- if len(sys.argv) != 3:
- print "usage: build.py <src dir> <output dir>"
- sys.exit(-1)
-
- src_dir = sys.argv[1]
- dest_dir = sys.argv[2]
-
- #build_rfcs(src_dir, dest_dir)
- copy_static(dest_dir)
- generate_site_index(dest_dir)
-
-if __name__ == '__main__':
- main()
+++ /dev/null
-# We're getting RFCs from the IETF's rsync server.
-# These RFCs are in text format, so we need to use the
-# IETF's rfcmarkup to convert them to HTML. This html is
-# then used by format-rfc to make a pretty rfc.
-import sys
-import subprocess
-from os import listdir
-from os.path import (isfile, join, getmtime, splitext,
- basename, dirname)
-
-
-def list_files(directory, extension=''):
- l = []
- files = listdir(directory)
-
- for f in files:
- filename, ext = splitext(f)
- if isfile(join(directory, f)) and extension in ext:
- l.append(filename)
- return l
-
-
-def build_file(infile, outfile):
- with open(outfile, 'w+') as fd:
- command = ['python', 'src/rfcmarkup', dirname(infile), infile]
- subprocess.call(command, stdout=fd)
-
-def convert_rfc_html(src_dir, dest_dir):
- src_files = {filename: join(src_dir, filename) for filename in list_files(src_dir, 'txt')}
- dest_files = {filename: join(dest_dir, filename) for filename in list_files(dest_dir, 'html')}
-
- for filename in src_files:
- src_path = join(src_dir, filename) + '.txt'
- dest_path = join(dest_dir, filename) + '.html'
-
- if filename not in dest_files or getmtime(src_path) > getmtime(dest_path):
- print "Building {}".format(src_path)
- build_file(src_path, dest_path)
-
-
-if __name__ == '__main__':
- main()
jinja2==2.8
+flask==0.10.1
+gevent==1.1.0
+gunicorn==19.4.5