Compare commits
5 Commits
5a5692d8cc
...
40bead1e6a
Author | SHA1 | Date | |
---|---|---|---|
40bead1e6a | |||
4b50711cd3 | |||
3f1ebfbac0 | |||
ce6572b81b | |||
bcab963b99 |
41
app.py
41
app.py
@ -26,7 +26,8 @@ else:
|
|||||||
app.config.from_object(DevelopmentConfig)
|
app.config.from_object(DevelopmentConfig)
|
||||||
cache = Cache(app, config={"CACHE_TYPE": "SimpleCache"})
|
cache = Cache(app, config={"CACHE_TYPE": "SimpleCache"})
|
||||||
|
|
||||||
ocr = PaddleOCR(use_angle_cls=True, lang='en') # Adjust language if needed
|
if app.config.get("OCR_ENABLED"):
|
||||||
|
ocr = PaddleOCR(use_angle_cls=True, lang='en') # Adjust language if needed
|
||||||
|
|
||||||
app.config["SESSION_COOKIE_SECURE"] = not app.config["DEBUG"]
|
app.config["SESSION_COOKIE_SECURE"] = not app.config["DEBUG"]
|
||||||
app.config['SESSION_COOKIE_HTTPONLY'] = True # Prevent JavaScript access
|
app.config['SESSION_COOKIE_HTTPONLY'] = True # Prevent JavaScript access
|
||||||
@ -85,6 +86,7 @@ def home():
|
|||||||
accounts=count,
|
accounts=count,
|
||||||
current_month_accounts=current_month_accounts,
|
current_month_accounts=current_month_accounts,
|
||||||
expired_accounts=expired_accounts,
|
expired_accounts=expired_accounts,
|
||||||
|
ocr_enabled=app.config.get("OCR_ENABLED"),
|
||||||
)
|
)
|
||||||
return render_template("index.html")
|
return render_template("index.html")
|
||||||
|
|
||||||
@ -163,7 +165,7 @@ def add_account():
|
|||||||
return redirect(url_for("user_accounts"))
|
return redirect(url_for("user_accounts"))
|
||||||
return render_template("add_account.html")
|
return render_template("add_account.html")
|
||||||
|
|
||||||
return render_template("add_account.html")
|
return render_template("add_account.html", ocr_enabled=app.config.get("OCR_ENABLED"), text_input_enabled=app.config.get("TEXT_INPUT_ENABLED"))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/accounts/delete", methods=["POST"])
|
@app.route("/accounts/delete", methods=["POST"])
|
||||||
@ -187,23 +189,24 @@ def stream_names():
|
|||||||
return jsonify(stream_names)
|
return jsonify(stream_names)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/OCRupload', methods=['POST'])
|
if app.config.get("OCR_ENABLED"):
|
||||||
def OCRupload():
|
@app.route('/OCRupload', methods=['POST'])
|
||||||
if 'image' not in request.files:
|
def OCRupload():
|
||||||
return jsonify({"error": "No image file found"}), 400
|
if 'image' not in request.files:
|
||||||
# Get the uploaded file
|
return jsonify({"error": "No image file found"}), 400
|
||||||
file = request.files['image']
|
# Get the uploaded file
|
||||||
try:
|
file = request.files['image']
|
||||||
image = Image.open(file.stream)
|
try:
|
||||||
image_np = np.array(image)
|
image = Image.open(file.stream)
|
||||||
result = ocr.ocr(image_np)
|
image_np = np.array(image)
|
||||||
# Extract text
|
result = ocr.ocr(image_np)
|
||||||
extracted_text = []
|
# Extract text
|
||||||
for line in result[0]:
|
extracted_text = []
|
||||||
extracted_text.append(line[1][0])
|
for line in result[0]:
|
||||||
return render_template("add_account.html", username=extracted_text[2], password=extracted_text[3])
|
extracted_text.append(line[1][0])
|
||||||
except Exception as e:
|
return render_template("add_account.html", username=extracted_text[2], password=extracted_text[3])
|
||||||
return jsonify({"error": str(e)}), 500
|
except Exception as e:
|
||||||
|
return jsonify({"error": str(e)}), 500
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(debug=app.config["DEBUG"], host=app.config["HOST"], port=app.config["PORT"])
|
app.run(debug=app.config["DEBUG"], host=app.config["HOST"], port=app.config["PORT"])
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
[tool.bump-my-version]
|
|
||||||
current_version = "1.0.6"
|
|
||||||
commit = true
|
|
||||||
tag = true
|
|
||||||
message = "bump version to {new_version}"
|
|
||||||
|
|
||||||
[[tool.bump-my-version.files]]
|
|
||||||
filename = "VERSION"
|
|
@ -74,6 +74,7 @@
|
|||||||
<span id="buttonText">Add Account</span>
|
<span id="buttonText">Add Account</span>
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
{% if ocr_enabled %}
|
||||||
<hr>
|
<hr>
|
||||||
<h2>Load Details Via OCR</h2>
|
<h2>Load Details Via OCR</h2>
|
||||||
<form action="/OCRupload" method="POST" enctype="multipart/form-data" onsubmit="showLoadingOCR()">
|
<form action="/OCRupload" method="POST" enctype="multipart/form-data" onsubmit="showLoadingOCR()">
|
||||||
@ -86,6 +87,15 @@
|
|||||||
<span id="ocrButtonText">Load Details</span>
|
<span id="ocrButtonText">Load Details</span>
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
{% endif %}
|
||||||
|
{% if text_input_enabled %}
|
||||||
|
<hr>
|
||||||
|
<h2>Load Details Via Text</h2>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="accountDetails">Paste Account Details</label>
|
||||||
|
<textarea class="form-control" id="accountDetails" rows="4"></textarea>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
<footer class="bg-dark text-white text-center py-3 mt-5">
|
<footer class="bg-dark text-white text-center py-3 mt-5">
|
||||||
@ -106,12 +116,47 @@
|
|||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
var streamInput = document.getElementById("stream");
|
var streamInput = document.getElementById("stream");
|
||||||
|
var awesomplete;
|
||||||
fetch('/get_stream_names')
|
fetch('/get_stream_names')
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
new Awesomplete(streamInput, {
|
awesomplete = new Awesomplete(streamInput, {
|
||||||
list: data
|
list: data
|
||||||
});
|
});
|
||||||
|
|
||||||
|
streamInput.addEventListener('awesomplete-selectcomplete', function(event) {
|
||||||
|
this.value = event.text.value;
|
||||||
|
});
|
||||||
|
|
||||||
|
{% if text_input_enabled %}
|
||||||
|
const accountDetailsTextarea = document.getElementById('accountDetails');
|
||||||
|
if (accountDetailsTextarea) {
|
||||||
|
accountDetailsTextarea.addEventListener('input', function() {
|
||||||
|
const text = this.value;
|
||||||
|
const lines = text.split('\n');
|
||||||
|
|
||||||
|
const streamName = lines[0] ? lines[0].trim() : '';
|
||||||
|
const usernameLine = lines.find(line => line.toUpperCase().startsWith('USER:'));
|
||||||
|
const passwordLine = lines.find(line => line.toUpperCase().startsWith('PASS:'));
|
||||||
|
|
||||||
|
if (usernameLine) {
|
||||||
|
document.getElementById('username').value = usernameLine.substring(5).trim();
|
||||||
|
}
|
||||||
|
if (passwordLine) {
|
||||||
|
document.getElementById('password').value = passwordLine.substring(5).trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (streamName) {
|
||||||
|
streamInput.value = streamName;
|
||||||
|
awesomplete.evaluate();
|
||||||
|
if (awesomplete.ul.children.length > 0) {
|
||||||
|
awesomplete.goto(0);
|
||||||
|
awesomplete.select();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user