diff --git a/backend/api-docs.txt b/backend/api-docs.txt index aba2f79..bb38c4c 100644 --- a/backend/api-docs.txt +++ b/backend/api-docs.txt @@ -1,7 +1,3 @@ -WARNING:- - This api is not yet capable of handling any exceptions that may arise when opened for the first time - - _____________________ Login:- URL:- /login diff --git a/backend/rest_api.py b/backend/rest_api.py index b8764b5..1187cf9 100644 --- a/backend/rest_api.py +++ b/backend/rest_api.py @@ -1,18 +1,27 @@ -from os import path +from os import mkdir, path from flask import Flask, request, send_file, abort, Response from werkzeug.datastructures import ImmutableMultiDict from data_handler import DataHandler +import appdirs app: Flask = Flask(__name__) + +def handle_first_launched(): + folder_path: str = appdirs.user_data_dir(appname="Unnamed_Password_Manager") + if not path.exists(folder_path): + mkdir(folder_path) + + @app.get("/") @app.get("/") def handle_get(url_path: str = "index.html") -> Response: """ Handle all get requests that are made. """ + handle_first_launched() requested_file_path: str = \ path.abspath(path.join(path.curdir, "..", "frontend", url_path)) response: Response = send_file(requested_file_path)