# LibreVax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with LibreVax. If not, see <https://www.gnu.org/licenses/>.
-from flask import Flask, render_template, request, session, redirect, g
+from flask import Flask, render_template, request, session, redirect, send_file, g
from urllib.parse import urlencode
from datetime import datetime
import json, sqlite3
raise(e)
return render_template("error.html", data=e)
+@app.get("/dump")
+def dump(msg=None):
+ if((ret:=problem())!="go"):
+ return ret
+ try:
+ if(g.user!="admin"):
+ raise PermissionError
+ return send_file("data/database.db", as_attachment=True, download_name="backup-"+str(datetime.now())+".db")
+ except PermissionError as e:
+ return render_template("error.html", data="Access Denied")
+ except Exception as e:
+ raise(e)
+ return render_template("error.html", data=e)
+
def get_db():
db=getattr(g, "_database", None)
if db is None: