]> khamidou — GitHub mirrors - rfcspot.git/commitdiff
Add heroku files
authorKarim Hamidou <khamidou@gmail.com>
Thu, 17 Mar 2016 01:45:45 +0000 (18:45 -0700)
committerKarim Hamidou <khamidou@gmail.com>
Thu, 17 Mar 2016 01:45:45 +0000 (18:45 -0700)
Procfile [new file with mode: 0644]
app.py [new file with mode: 0644]
build.py [deleted file]
convert_txt_rfc_to_html.py [deleted file]
requirements.txt

diff --git a/Procfile b/Procfile
new file mode 100644 (file)
index 0000000..91f7f3b
--- /dev/null
+++ b/Procfile
@@ -0,0 +1 @@
+web: gunicorn -w 4 -b 0.0.0.0:$PORT -k gevent app:app
diff --git a/app.py b/app.py
new file mode 100644 (file)
index 0000000..bb211f9
--- /dev/null
+++ b/app.py
@@ -0,0 +1,46 @@
+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)
diff --git a/build.py b/build.py
deleted file mode 100644 (file)
index 210f52f..0000000
--- a/build.py
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/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()
diff --git a/convert_txt_rfc_to_html.py b/convert_txt_rfc_to_html.py
deleted file mode 100644 (file)
index 3c84260..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-# 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()
index 31c0090e21275f13d56ce43de0be91d8675d428b..da9da8b620210ef808baac67441e1f0a6c0ee522 100644 (file)
@@ -1 +1,4 @@
 jinja2==2.8
+flask==0.10.1
+gevent==1.1.0
+gunicorn==19.4.5