Skip to content

Commit

Permalink
feat: allow method overwrite on POST FORM request
Browse files Browse the repository at this point in the history
  • Loading branch information
nhymxu committed Aug 1, 2024
1 parent b32bbfc commit 4a0ddc8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion web.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from a2wsgi import WSGIMiddleware
from dotenv import load_dotenv
from flask import send_file
from flask import request, send_file

from logics.auth_middleware import require_authentication
from logics.webserver import create_app
Expand All @@ -14,6 +14,14 @@
asgi_app = WSGIMiddleware(app)


@app.before_request
def method_override():
if request.method == 'POST' and '_method' in request.form:
method = request.form['_method'].upper()
if method in ['PUT', 'DELETE', 'PATCH']:
request.environ['REQUEST_METHOD'] = method


@app.get('/favicon.ico')
def get_favicon():
# 1x1 transparent gif
Expand Down

0 comments on commit 4a0ddc8

Please sign in to comment.