Skip to content
This repository was archived by the owner on May 11, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cache/v/cache/lastfailed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
6 changes: 6 additions & 0 deletions .cache/v/pep8/mtimes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"/Users/chaim/Dropbox/github/flask-modus/test_flask_modus.py": [
1503164934.0,
[]
]
}
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
language: python
python:
- "2.7"
- "3.6"
env:
- FLASK_VERSION=0.8
- FLASK_VERSION=0.9
- FLASK_VERSION=0.10
- FLASK_VERSION=0.12
install:
- "pip install -r requirements.txt"
- "pip install -I Flask==$FLASK_VERSION"
script: "invoke travisci"
script: "invoke travisci"
matrix:
exclude:
- python: "3.6"
env: FLASK_VERSION=0.8
- python: "3.6"
env: FLASK_VERSION=0.9
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Flask-Modus
=====================
This is the same flask_modus as done by Rhys Elsmore with a slight change by Chaim Finkelman to make it work with both python 3.6 and 2.7 .


.. image:: https://secure.travis-ci.org/rhyselsmore/flask-modus.png?branch=master

Expand Down
5 changes: 3 additions & 2 deletions flask_modus.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

from werkzeug import url_decode

from sys import version_info

class Middleware(object):
""" WSGI Method Overriding Middleware """
Expand All @@ -26,7 +26,8 @@ def __call__(self, environ, response):

def set_method(method):
if method in self.allowed_methods:
method = method.encode('ascii', 'replace')
if version_info[0] < 3:
method = method.encode('ascii', 'replace')
environ['REQUEST_METHOD'] = method
if method in self.bodyless_methods:
environ['CONTENT_LENGTH'] = '0'
Expand Down
4 changes: 2 additions & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@


@task
def test():
def test(ctx):
run('py.test --pep8 --cov=flask_modus test_flask_modus.py', pty=True)


@task
def travisci():
def travisci(ctx):
run('py.test --pep8 test_flask_modus.py')
6 changes: 3 additions & 3 deletions test_flask_modus.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ def put():
def test_get(self):
""" Test get """

assert "get" in self.client.get('/').data
assert "get" in self.client.get('/').data.decode('ascii')

def test_query_string(self):
""" Test put """

rv = self.client.put('/')
assert "put" in rv.data
assert "put" in rv.data.decode('ascii')
rv = self.client.post('/?_method=put')
assert "put" in rv.data
assert "put" in rv.data.decode('ascii')

with self.app.test_client() as c:
c.post('/?_method=put')
Expand Down