Limit methods to GET

This commit is contained in:
Tim Van Baak 2021-02-12 17:51:46 -08:00
parent 8bd8bdf269
commit fc74673bb2
1 changed files with 4 additions and 4 deletions

View File

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