Commit e922d3bf5acdc767fa17ddc2ac7302665488cae6
Module logging is to be imported in a specific order, otherwise it fails loading. +Indentation fixes.
| | | | 2 | from flask import request | 2 | from flask import request |
---|
3 | from flask import render_template | 3 | from flask import render_template |
---|
4 | from flask import make_response | 4 | from flask import make_response |
---|
| | 5 | import logging |
---|
5 | from logging import FileHandler | 6 | from logging import FileHandler |
---|
6 | import json | 7 | import json |
---|
7 | import pymongo | 8 | import pymongo |
---|
… | | … | |
---|
24 | filename = request.args['json'] | 24 | filename = request.args['json'] |
---|
25 | else: | 25 | else: |
---|
26 | filename = 'test.json' | 26 | filename = 'test.json' |
---|
27 | filename = os.path.join('static', filename) | | filename = os.path.join('static', filename) |
---|
28 | try: | | try: |
---|
29 | f = open(filename, 'r') | | f = open(filename, 'r') |
---|
30 | except: | | except: |
---|
31 | f = open('static/test.json', 'r') | | f = open('static/test.json', 'r') |
---|
32 | buf = f.read() | | buf = f.read() |
---|
33 | f.close() | | f.close() |
---|
34 | return render_template('editor.html', json = buf) | | return render_template('editor.html', json = buf) |
---|
| | 27 | filename = os.path.join('static', filename) | | | 28 | try: |
---|
| | 29 | f = open(filename, 'r') |
---|
| | 30 | except: |
---|
| | 31 | f = open('static/test.json', 'r') |
---|
| | 32 | buf = f.read() |
---|
| | 33 | f.close() |
---|
| | 34 | return render_template('editor.html', json = buf) |
---|
35 | | 35 | |
---|
36 | @app.route('/saveJSON', methods=['POST']) | 36 | @app.route('/saveJSON', methods=['POST']) |
---|
37 | def saveJSON(): | 37 | def saveJSON(): |
---|