Addon to Flask to edit HTML content in a running app.
Project description
Editable Flask ๐โจ
Tired of constant client requests to tweak that elusive snippet or image on your /about page? Enter EditableFlask! Simply mark sections of your templates with {% editable %}, and voilร , they're ready for modification in a sleek admin panel. Say goodbye to the hassle of copy adjustments. ๐
๐ Installation
pip install EditableFlask
๐ ๏ธ Usage
from flask import Flask
from EditableFlask import Edits
app = Flask(__name__)
edits = Edits(app)
All edits are neatly saved to disk as JSON. Configure your file path to store them alongside your app:
from flask import Flask, render_template
from EditableFlask import Edits
import os
app = Flask(__name__)
app.config['FILE_PATH'] = os.path.dirname(__file__)
edits = Edits(app)
@app.route("/")
def index():
return render_template('index.html')
๐น Example (Live Editing in Templates)
<!-- index.html -->
<!DOCTYPE html>
<html>
<body>
<h1>{% editable 'heading' %}My First Heading{% endeditable %}</h1>
<p>{% editable 'paragraph' %}My first paragraph.{% endeditable %}</p>
</body>
</html>
โ๏ธ Edits Section
Edit any page with registered editable sections directly in the interface. Currently, only static HTML is supported, with Jinja2 support on the roadmap.
๐ Summernote Features
Enable the Summernote HTML Editor for enhanced editing:
app.config['EDITS_SUMMERNOTE'] = True
๐ Features:
- Upload Images/Videos ๐ผ๏ธ๐ฅ
- Rich Text Formatting ๐จ
- Advanced Editing (Tables, Code Blocks, LaTeX Equations)
For more details, visit SUMMERNOTE's Website.
๐ Security
๐ Recommended: Flask-Login (Session-Based Lock)
app.config['EDITS_LOCKED'] = True
app.config['EDITS_USERNAME'] = 'your_username'
app.config['EDITS_PASSWORD'] = 'your_password'
๐น Session-Based Locks prevent unauthorized access. ๐น Local Caching for Locking ensures a lightweight security approach.
๐ Recommended: SQLite-Based Lock
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///users.db'
app.config['EDITS_LOCKED'] = "SQL"
๐น Database-Controlled Edit Locks ๐น Audit Trail for Edits for accountability ๐น Granular Access Control ensures secure editing
๐ง Manual Lock (Custom Auth)
If you already have a user-management system:
@app.before_request
def before_request():
if request.path.startswith(app.config.get('EDITS_URL')):
# Custom authentication logic
๐น Flexible Authentication ๐น User-Defined Locking Mechanism
๐ Additional Features
๐ Analytics Dashboard
Enable it with:
app.config['ENABLE_ANALYTICS'] = True
๐น Tracks Unique IP Visits (15-min timeout) ๐น Displays Visitor Locations on a map ๐น Monitors Server Resource Usage
๐ป Resource Monitoring
Enable it with:
app.config['ENABLE_RESOURCE_MONITOR'] = True
๐น Real-time CPU & RAM Usage ๐น Disk Usage Insights ๐น Graphical Resource Visualization
๐ Static File Management
Enable static file editing:
app.config['ENABLE_STATIC'] = True
app.config['EDITABLE_STATIC'] = True
๐น File Uploads & Folder Management ๐น Live Editing for Static Files ๐น Search & Deletion Support
๐ Folder Structure
/your_flask_project
โโโ app.py # Main Flask app file
โโโ templates/
โ โโโ index.html # Main template file
โโโ static/ # CSS, JS, images, etc.
โโโ edits.json # EditableFlask Edits saved (EditableFlask Managed)
โโโ intents/ # SQLite database (if used)
โ โโโ *.db # Database File (EditableFlask Managed)
For more details, refer to the Flask Documentation.
โ๏ธ Configuration Options
Customize EditableFlask with various settings to enhance functionality, security, and performance. This guide explains key configurations and their purpose.
๐ Application Settings
EditableFlask allows you to customize its name and branding. These settings determine how the app appears in titles and throughout the UI.
app.config['APP_NAME'] = 'EditableFlask' # Display name for the app (used in <title> tags)
app.config['APP_NAME_HTML'] = 'EditableFlask' # Name used throughout web pages and UI
๐ URL Routing
Define essential URL routes for the application. These settings control access to key pages, such as the admin dashboard and login screen.
app.config['EDITS_URL'] = '/edits' # URL for the admin dashboard
app.config['LOGIN_ROUTE'] = '/login' # Login page route
๐ Session Management
Manage user sessions and authentication timeouts. This setting controls how long a user stays logged in before needing to re-authenticate.
from datetime import timedelta
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(minutes=60) # User session timeout duration
๐๏ธ Database Configuration
Define how the application interacts with the database. These settings determine connection parameters and performance optimizations.
-
SQLALCHEMY_DATABASE_URI
Specifies the database connection string. By default, it uses SQLite with a file namedusers.db, but it can be customized for PostgreSQL, MySQL, etc.app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///users.db'
-
SQLALCHEMY_TRACK_MODIFICATIONS
Controls whether SQLAlchemy tracks object modifications and emits signals. Keeping this disabled improves performance unless event tracking is needed.app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
Resources ๐
๐น MDI Icons From pictogrammers ๐น Flask ๐น Jinja ๐น Flask-Login ๐น Flask-SQLAlchemy ๐น SQLAlchemy ๐น psutil ๐น platform ๐น socket ๐น subprocess ๐น datetime ๐น HTML CSS JS ๐น Bootstrap ๐น jQuery.ajax ๐น OpenStreetMap ๐น Chart.js
Authors โ๏ธ
View This Repository on GitHub: EditableFlask
Support ๐ฌ
For support, email info@mahirshah.dev or contact me through my Website.
License ๐
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the โSoftwareโ), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED โAS ISโ, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGE
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file editableflask-2.0.0.1.tar.gz.
File metadata
- Download URL: editableflask-2.0.0.1.tar.gz
- Upload date:
- Size: 392.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e1d2aad3f03ae6a59b8bc76c6bd8c4698f518c1bf2cd42b4c312b0ead26e560
|
|
| MD5 |
78b3f46fc2016fdb25462438a020f1d0
|
|
| BLAKE2b-256 |
a8948634415a79d6ee2655ca3c1f1747b8527a7c6d22fb3bd60f8103db0a5cf9
|
File details
Details for the file editableflask-2.0.0.1-py3-none-any.whl.
File metadata
- Download URL: editableflask-2.0.0.1-py3-none-any.whl
- Upload date:
- Size: 403.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01ab69d513bab6c7237033d973888931bbcc96a77a667b15e7d2910174949e57
|
|
| MD5 |
097458ef41646b70f0e2d2dd6ac7bb90
|
|
| BLAKE2b-256 |
0bb0dc3022a830ebf4e00db917efefd2f926a7d7187e15cfa5e3e5a776302c25
|