- version : 0.7
- description : adding download template option and move (template.csv -> templates/template.csv).
هذا الالتزام موجود في:
9
app.py
9
app.py
@@ -2,7 +2,7 @@ import sqlite3
|
||||
import csv
|
||||
import io
|
||||
import re
|
||||
from flask import Flask, render_template, request, redirect, url_for, flash
|
||||
from flask import Flask, render_template, request, redirect, url_for, flash, send_from_directory
|
||||
|
||||
# --- App Setup ---
|
||||
app = Flask(__name__)
|
||||
@@ -228,5 +228,12 @@ def import_csv():
|
||||
|
||||
return redirect(url_for('index'))
|
||||
|
||||
# New route to download the CSV template
|
||||
@app.route('/download_csv_template')
|
||||
def download_csv_template():
|
||||
# The directory where the template.csv is located (your templates folder)
|
||||
# The second argument is the filename to be sent
|
||||
return send_from_directory(app.template_folder, 'template.csv', as_attachment=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True)
|
||||
@@ -71,6 +71,12 @@
|
||||
<code class="text-xs font-mono">اسم الطالب, العمر, اسم ولي الأمر, هاتف ولي الأمر 1, هاتف ولي الأمر 2, هاتف الطالب, الصف, اسم المدرسة, العنوان, المحفوظات</code>
|
||||
</p>
|
||||
<p>إذا كانت الحقول الاختيارية (هاتف ولي الأمر 2، هاتف الطالب) فارغة، اتركها كذلك.</p>
|
||||
{# Added link to download CSV template #}
|
||||
<p class="mt-3">
|
||||
<a href="{{ url_for('download_csv_template') }}" class="text-blue-600 hover:underline font-semibold" download>
|
||||
تنزيل قالب CSV
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="mt-6 text-left">
|
||||
<form id="import-form" action="{{ url_for('import_csv') }}" method="POST" enctype="multipart/form-data">
|
||||
@@ -89,6 +95,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="bg-white p-6 rounded-xl shadow-lg">
|
||||
<div class="flex justify-between items-center mb-4 pb-4 border-b">
|
||||
<h2 class="text-2xl font-semibold text-gray-800">الطلاب المسجلون</h2>
|
||||
|
||||
|
لا يمكن عرض هذا الملف لأنه يحتوي على عدد خاطئ من الحقول في السطر 5.
|
المرجع في مشكلة جديدة
حظر مستخدم