semvec/pypi-packages huggingface dataset:
pyeasycsrf 0.4.2
pyeasycsrf It is a simple python library To generate a CSRF token To protect your falsk app
License: MIT
Requires Python: >=3.1.0


# pyeasycsrf

## Installation

* From PyPi
```
python pip install pyeasycsrf
````

## how to use it

```python

from pyeasycsrf import CsrfTokenGenerator

CsrfGenerator = CsrfTokenGenerator()

```


```
in default CsrfTokenGenerator(length = 1, tokens_file= 'tokens.txt') 
length = 1 return 32 random numbers and liiters

````


## generate token and add token to signup page

```python

from pyeasycsrf import CsrfTokenGenerator

CsrfGenerator = CsrfTokenGenerator()


@app.route('/signup', methods = ['GET'])
def signup():
	if request.method == 'GET':
		return render_template('signup.html', csrf_token = CsrfGenerator.generate_token())

```

### <input type="hidden" name="csrf_token" value="{{ csrf_token }}"/>


## get and verify csrf token

```python

from pyeasycsrf import CsrfTokenGenerator

@app.route('/api/signup', methods = ['POST'])
def api_signup():
    data = request.get_json()
    return {"token": data['csrf_token']}


```