Skip to content

Instantly share code, notes, and snippets.

@tarmstrong
Created October 7, 2013 04:42
Show Gist options
  • Save tarmstrong/6862642 to your computer and use it in GitHub Desktop.
Save tarmstrong/6862642 to your computer and use it in GitHub Desktop.
Gist of the nbdiff backend (very rough idea)
from flask import Flask
class NBDiffFlask(Flask):
def set_files(self, file1, file2):
self.file1 = file1
self.file2 = file2
app = NBDiffFlask(__name__)
@app.route("/diff.js")
def diff():
return open('src/JSDiff/diff.js').read()
@app.route("/")
def main():
return open('src/JSDiff/diff.html').read()
@app.route("/file1.json")
def file1():
return open(app.file1).read()
@app.route("/file2.json")
def file2():
return open(app.file2).read()
def main():
import argparse
parser = argparse.ArgumentParser(__name__)
parser.add_argument('file1')
parser.add_argument('file2')
args = parser.parse_args()
app.set_files(args.file1, args.file2)
app.run()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment