Limit methods to GET

This commit is contained in:
Tim Van Baak 2021-02-12 17:51:46 -08:00
parent 8bd8bdf269
commit fc74673bb2

View File

@ -23,18 +23,18 @@ CONFIG_ENVVAR = 'REDSTRING_CONFIG'
app = Flask(__name__)
@app.route('/')
@app.route('/', methods=['GET'])
def root():
return redirect(url_for('index'))
@app.route('/index/')
@app.route('/index/', methods=['GET'])
def index():
document = generate_index_document(current_app.config['root'])
return render_template('doc.jinja', document=document, index=True)
@app.route('/doc/<document_id>')
@app.route('/doc/<document_id>', methods=['GET'])
def document(document_id):
doc_path = safe_join(current_app.config['root'], f'{document_id}.json')
if not os.path.isfile(doc_path):
@ -44,7 +44,7 @@ def document(document_id):
return render_template('doc.jinja', document=doc, index=False)
@app.route('/new/')
@app.route('/new/', methods=['GET'])
def new():
document_id = 'new'
new_doc = generate_default_document(document_id)