Flask-Obfuscate is a Flask extension that obfuscates HTML responses to help protect your HTML content from easy inspection or copying. This extension processes all HTML responses and converts them into obfuscated JavaScript that writes the HTML content when executed in a browser.
- Obfuscates HTML responses by converting them to JavaScript
- Easy to integrate into existing Flask applications
- Simple usage with minimal configuration
You can install Flask-Obfuscate via pip:
pip install Flask-Obfuscate
Integrate Flask-Obfuscate into your Flask application with minimal setup:
from flask import Flask
from flask_obfuscate import Obfuscate
app = Flask(__name__)
obfuscate = Obfuscate(app)
@app.route('/')
def index():
return '<div>Hello, World!</div>'
if __name__ == '__main__':
app.run(debug=True)
You can also initialize Flask-Obfuscate later using the init_app
method:
from flask import Flask
from flask_obfuscate import Obfuscate
app = Flask(__name__)
obfuscate = Obfuscate()
obfuscate.init_app(app)
@app.route('/')
def index():
return '<div>Hello, World!</div>'
if __name__ == '__main__':
app.run(debug=True)
To run the tests, first install the test dependencies:
pip install pytest
Then you can run the tests using pytest:
pytest tests
Contributions are welcome! Please submit a pull request or open an issue to discuss improvements or fixes.
- Fork the repository.
- Create a new branch:
git checkout -b my-feature-branch
- Make your changes and commit them:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-feature-branch
- Submit a pull request.
This project is licensed under the MIT License.
Inspired by the need to protect HTML content in Flask applications.