Spaces:
Sleeping
Sleeping
Commit ·
ff50748
1
Parent(s): 61fcdc2
Deploy to HF Spaces as Docker sdk
Browse files- Dockerfile +22 -0
- README.md +1 -2
- app.js +2 -13
- index.html +22 -22
- js/api/hfService.js +1 -1
- server/app.py +3 -2
Dockerfile
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.9-slim
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
# Give permissions to create folders
|
| 6 |
+
RUN mkdir -p /app/data /app/logs && chmod 777 /app/data /app/logs
|
| 7 |
+
|
| 8 |
+
# Install dependencies
|
| 9 |
+
COPY ./server/requirements.txt /app/requirements.txt
|
| 10 |
+
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
|
| 11 |
+
|
| 12 |
+
# Copy application files
|
| 13 |
+
COPY . /app
|
| 14 |
+
|
| 15 |
+
# Ensure correct permissions after copy
|
| 16 |
+
RUN chmod -R 777 /app/data /app/logs
|
| 17 |
+
|
| 18 |
+
# Expose port (default for HF Spaces)
|
| 19 |
+
EXPOSE 7860
|
| 20 |
+
|
| 21 |
+
# Command to run the standard Flask app
|
| 22 |
+
CMD ["python", "server/app.py"]
|
README.md
CHANGED
|
@@ -3,8 +3,7 @@ title: DocVault App
|
|
| 3 |
emoji: 📁
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: purple
|
| 6 |
-
sdk:
|
| 7 |
-
app_file: index.html
|
| 8 |
pinned: false
|
| 9 |
---
|
| 10 |
|
|
|
|
| 3 |
emoji: 📁
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: purple
|
| 6 |
+
sdk: docker
|
|
|
|
| 7 |
pinned: false
|
| 8 |
---
|
| 9 |
|
app.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
// DocVault — Offline-First Document Storage System
|
| 2 |
// Uses local Flask backend for all operations
|
| 3 |
|
| 4 |
-
const API_BASE = '
|
| 5 |
const USER_ID = 'default_user';
|
| 6 |
const DEFAULT_FOLDER = '';
|
| 7 |
|
|
@@ -950,37 +950,26 @@ function setNavActive(nav) {
|
|
| 950 |
}
|
| 951 |
|
| 952 |
navMyFiles.addEventListener('click', (e) => {
|
| 953 |
-
console.log('navMyFiles clicked'); // Debug
|
| 954 |
e.preventDefault();
|
| 955 |
e.stopPropagation();
|
| 956 |
e.stopImmediatePropagation();
|
| 957 |
-
currentBrowse = 'files';
|
| 958 |
-
currentPath = [];
|
| 959 |
setNavActive(navMyFiles);
|
| 960 |
fetchAndRender();
|
| 961 |
-
return false;
|
| 962 |
});
|
| 963 |
|
| 964 |
navRecent.addEventListener('click', (e) => {
|
| 965 |
-
console.log('navRecent clicked'); // Debug
|
| 966 |
e.preventDefault();
|
| 967 |
-
e.stopPropagation();
|
| 968 |
-
e.stopImmediatePropagation();
|
| 969 |
currentBrowse = 'recent';
|
| 970 |
setNavActive(navRecent);
|
| 971 |
renderRecentView();
|
| 972 |
-
return false;
|
| 973 |
});
|
| 974 |
|
| 975 |
navStarred.addEventListener('click', (e) => {
|
| 976 |
-
console.log('navStarred clicked'); // Debug
|
| 977 |
e.preventDefault();
|
| 978 |
-
e.stopPropagation();
|
| 979 |
-
e.stopImmediatePropagation();
|
| 980 |
currentBrowse = 'starred';
|
| 981 |
setNavActive(navStarred);
|
| 982 |
renderStarredView();
|
| 983 |
-
return false;
|
| 984 |
});
|
| 985 |
|
| 986 |
function renderRecentView() {
|
|
|
|
| 1 |
// DocVault — Offline-First Document Storage System
|
| 2 |
// Uses local Flask backend for all operations
|
| 3 |
|
| 4 |
+
const API_BASE = '/api';
|
| 5 |
const USER_ID = 'default_user';
|
| 6 |
const DEFAULT_FOLDER = '';
|
| 7 |
|
|
|
|
| 950 |
}
|
| 951 |
|
| 952 |
navMyFiles.addEventListener('click', (e) => {
|
|
|
|
| 953 |
e.preventDefault();
|
| 954 |
e.stopPropagation();
|
| 955 |
e.stopImmediatePropagation();
|
| 956 |
+
currentBrowse = 'files'; currentPath = [];
|
|
|
|
| 957 |
setNavActive(navMyFiles);
|
| 958 |
fetchAndRender();
|
|
|
|
| 959 |
});
|
| 960 |
|
| 961 |
navRecent.addEventListener('click', (e) => {
|
|
|
|
| 962 |
e.preventDefault();
|
|
|
|
|
|
|
| 963 |
currentBrowse = 'recent';
|
| 964 |
setNavActive(navRecent);
|
| 965 |
renderRecentView();
|
|
|
|
| 966 |
});
|
| 967 |
|
| 968 |
navStarred.addEventListener('click', (e) => {
|
|
|
|
| 969 |
e.preventDefault();
|
|
|
|
|
|
|
| 970 |
currentBrowse = 'starred';
|
| 971 |
setNavActive(navStarred);
|
| 972 |
renderStarredView();
|
|
|
|
| 973 |
});
|
| 974 |
|
| 975 |
function renderRecentView() {
|
index.html
CHANGED
|
@@ -38,29 +38,29 @@
|
|
| 38 |
</div>
|
| 39 |
|
| 40 |
<div class="new-btn-wrapper">
|
| 41 |
-
<button
|
| 42 |
<i class="ph-bold ph-plus"></i> New
|
| 43 |
</button>
|
| 44 |
<div class="new-dropdown" id="newDropdown">
|
| 45 |
-
<button
|
| 46 |
<i class="ph-fill ph-folder-plus"></i> Create Folder
|
| 47 |
</button>
|
| 48 |
-
<button
|
| 49 |
<i class="ph-fill ph-upload-simple"></i> Upload File
|
| 50 |
</button>
|
| 51 |
</div>
|
| 52 |
</div>
|
| 53 |
|
| 54 |
<nav class="sidebar-nav">
|
| 55 |
-
<
|
| 56 |
<i class="ph-fill ph-folder"></i> My Files
|
| 57 |
-
</
|
| 58 |
-
<
|
| 59 |
<i class="ph-fill ph-clock-counter-clockwise"></i> Recent
|
| 60 |
-
</
|
| 61 |
-
<
|
| 62 |
<i class="ph-fill ph-star"></i> Starred
|
| 63 |
-
</
|
| 64 |
</nav>
|
| 65 |
|
| 66 |
<div class="sidebar-bottom">
|
|
@@ -102,8 +102,8 @@
|
|
| 102 |
<div class="section-header">
|
| 103 |
<h2>Folders</h2>
|
| 104 |
<div class="view-toggles">
|
| 105 |
-
<button
|
| 106 |
-
<button
|
| 107 |
</div>
|
| 108 |
</div>
|
| 109 |
<div class="grid-container" id="foldersContainer"></div>
|
|
@@ -121,14 +121,14 @@
|
|
| 121 |
<!-- Create Folder -->
|
| 122 |
<div class="modal-overlay" id="createFolderModal">
|
| 123 |
<div class="modal glass-panel">
|
| 124 |
-
<button
|
| 125 |
<h3><i class="ph-fill ph-folder-plus" style="color:var(--folder-color);margin-right:10px"></i>New Folder</h3>
|
| 126 |
<div class="input-group">
|
| 127 |
<input type="text" id="folderNameInput" placeholder="Enter folder name..." autocomplete="off">
|
| 128 |
</div>
|
| 129 |
<div class="modal-footer">
|
| 130 |
-
<button
|
| 131 |
-
<button
|
| 132 |
</div>
|
| 133 |
</div>
|
| 134 |
</div>
|
|
@@ -136,14 +136,14 @@
|
|
| 136 |
<!-- Delete Confirmation -->
|
| 137 |
<div class="modal-overlay" id="deleteModal">
|
| 138 |
<div class="modal glass-panel" style="max-width:360px">
|
| 139 |
-
<button
|
| 140 |
<div class="delete-icon-wrap"><i class="ph-fill ph-warning"></i></div>
|
| 141 |
<p style="text-align:center; margin-bottom:20px; font-size:15px; color:var(--text-main);">
|
| 142 |
Are you sure you want to delete <strong>this item</strong>?
|
| 143 |
</p>
|
| 144 |
<div class="modal-footer" style="justify-content:center;gap:16px">
|
| 145 |
-
<button
|
| 146 |
-
<button
|
| 147 |
</div>
|
| 148 |
</div>
|
| 149 |
</div>
|
|
@@ -151,15 +151,15 @@
|
|
| 151 |
<!-- Rename Modal -->
|
| 152 |
<div class="modal-overlay" id="renameModal">
|
| 153 |
<div class="modal glass-panel" style="max-width:400px">
|
| 154 |
-
<button
|
| 155 |
<h3><i class="ph-fill ph-pencil-simple" style="color:var(--primary-color)"></i> Rename File</h3>
|
| 156 |
<div class="input-group">
|
| 157 |
<label class="input-label">New Name</label>
|
| 158 |
<input type="text" id="renameInput" placeholder="Enter new name..." autocomplete="off">
|
| 159 |
</div>
|
| 160 |
<div class="modal-footer">
|
| 161 |
-
<button
|
| 162 |
-
<button
|
| 163 |
</div>
|
| 164 |
</div>
|
| 165 |
</div>
|
|
@@ -175,8 +175,8 @@
|
|
| 175 |
<span id="previewFileName">filename.pdf</span>
|
| 176 |
</div>
|
| 177 |
<div style="display:flex; gap:12px">
|
| 178 |
-
<button
|
| 179 |
-
<button
|
| 180 |
</div>
|
| 181 |
</div>
|
| 182 |
<div class="preview-body" id="previewBody">
|
|
|
|
| 38 |
</div>
|
| 39 |
|
| 40 |
<div class="new-btn-wrapper">
|
| 41 |
+
<button class="btn-primary new-btn" id="newBtn">
|
| 42 |
<i class="ph-bold ph-plus"></i> New
|
| 43 |
</button>
|
| 44 |
<div class="new-dropdown" id="newDropdown">
|
| 45 |
+
<button class="new-dropdown-item" id="createFolderBtn">
|
| 46 |
<i class="ph-fill ph-folder-plus"></i> Create Folder
|
| 47 |
</button>
|
| 48 |
+
<button class="new-dropdown-item" id="uploadFileBtn">
|
| 49 |
<i class="ph-fill ph-upload-simple"></i> Upload File
|
| 50 |
</button>
|
| 51 |
</div>
|
| 52 |
</div>
|
| 53 |
|
| 54 |
<nav class="sidebar-nav">
|
| 55 |
+
<a href="#" class="nav-item active" id="navMyFiles">
|
| 56 |
<i class="ph-fill ph-folder"></i> My Files
|
| 57 |
+
</a>
|
| 58 |
+
<a href="#" class="nav-item" id="navRecent">
|
| 59 |
<i class="ph-fill ph-clock-counter-clockwise"></i> Recent
|
| 60 |
+
</a>
|
| 61 |
+
<a href="#" class="nav-item" id="navStarred">
|
| 62 |
<i class="ph-fill ph-star"></i> Starred
|
| 63 |
+
</a>
|
| 64 |
</nav>
|
| 65 |
|
| 66 |
<div class="sidebar-bottom">
|
|
|
|
| 102 |
<div class="section-header">
|
| 103 |
<h2>Folders</h2>
|
| 104 |
<div class="view-toggles">
|
| 105 |
+
<button class="icon-btn active" id="viewGrid" title="Grid"><i class="ph-fill ph-squares-four"></i></button>
|
| 106 |
+
<button class="icon-btn" id="viewList" title="List"><i class="ph-fill ph-list-dashes"></i></button>
|
| 107 |
</div>
|
| 108 |
</div>
|
| 109 |
<div class="grid-container" id="foldersContainer"></div>
|
|
|
|
| 121 |
<!-- Create Folder -->
|
| 122 |
<div class="modal-overlay" id="createFolderModal">
|
| 123 |
<div class="modal glass-panel">
|
| 124 |
+
<button class="close-modal" id="closeNameModal"><i class="ph-bold ph-x"></i></button>
|
| 125 |
<h3><i class="ph-fill ph-folder-plus" style="color:var(--folder-color);margin-right:10px"></i>New Folder</h3>
|
| 126 |
<div class="input-group">
|
| 127 |
<input type="text" id="folderNameInput" placeholder="Enter folder name..." autocomplete="off">
|
| 128 |
</div>
|
| 129 |
<div class="modal-footer">
|
| 130 |
+
<button class="btn-secondary" id="cancelFolderBtn">Cancel</button>
|
| 131 |
+
<button class="btn-primary" id="confirmFolderBtn">Create</button>
|
| 132 |
</div>
|
| 133 |
</div>
|
| 134 |
</div>
|
|
|
|
| 136 |
<!-- Delete Confirmation -->
|
| 137 |
<div class="modal-overlay" id="deleteModal">
|
| 138 |
<div class="modal glass-panel" style="max-width:360px">
|
| 139 |
+
<button class="close-modal" id="closeDeleteModal"><i class="ph-bold ph-x"></i></button>
|
| 140 |
<div class="delete-icon-wrap"><i class="ph-fill ph-warning"></i></div>
|
| 141 |
<p style="text-align:center; margin-bottom:20px; font-size:15px; color:var(--text-main);">
|
| 142 |
Are you sure you want to delete <strong>this item</strong>?
|
| 143 |
</p>
|
| 144 |
<div class="modal-footer" style="justify-content:center;gap:16px">
|
| 145 |
+
<button class="btn-secondary" id="cancelDeleteBtn">Cancel</button>
|
| 146 |
+
<button class="btn-danger" id="confirmDeleteBtn"><i class="ph-fill ph-trash"></i> Delete</button>
|
| 147 |
</div>
|
| 148 |
</div>
|
| 149 |
</div>
|
|
|
|
| 151 |
<!-- Rename Modal -->
|
| 152 |
<div class="modal-overlay" id="renameModal">
|
| 153 |
<div class="modal glass-panel" style="max-width:400px">
|
| 154 |
+
<button class="close-modal" id="closeRenameModal"><i class="ph-bold ph-x"></i></button>
|
| 155 |
<h3><i class="ph-fill ph-pencil-simple" style="color:var(--primary-color)"></i> Rename File</h3>
|
| 156 |
<div class="input-group">
|
| 157 |
<label class="input-label">New Name</label>
|
| 158 |
<input type="text" id="renameInput" placeholder="Enter new name..." autocomplete="off">
|
| 159 |
</div>
|
| 160 |
<div class="modal-footer">
|
| 161 |
+
<button class="btn-secondary" id="cancelRenameBtn">Cancel</button>
|
| 162 |
+
<button class="btn-primary" id="confirmRenameBtn"><i class="ph-fill ph-check"></i> Rename</button>
|
| 163 |
</div>
|
| 164 |
</div>
|
| 165 |
</div>
|
|
|
|
| 175 |
<span id="previewFileName">filename.pdf</span>
|
| 176 |
</div>
|
| 177 |
<div style="display:flex; gap:12px">
|
| 178 |
+
<button class="icon-btn" id="downloadFromPreview" title="Download"><i class="ph-bold ph-download-simple"></i></button>
|
| 179 |
+
<button class="close-modal" id="closePreviewModal" style="position:static"><i class="ph-bold ph-x"></i></button>
|
| 180 |
</div>
|
| 181 |
</div>
|
| 182 |
<div class="preview-body" id="previewBody">
|
js/api/hfService.js
CHANGED
|
@@ -4,7 +4,7 @@ const CACHE_TTL = 5 * 60 * 1000; // 5 minutes
|
|
| 4 |
|
| 5 |
class HFService {
|
| 6 |
constructor() {
|
| 7 |
-
this.apiBase = '
|
| 8 |
this.cache = new Map();
|
| 9 |
this.retryLimit = 3;
|
| 10 |
this.retryDelay = 1000; // 1s start for exponential backoff
|
|
|
|
| 4 |
|
| 5 |
class HFService {
|
| 6 |
constructor() {
|
| 7 |
+
this.apiBase = '/api';
|
| 8 |
this.cache = new Map();
|
| 9 |
this.retryLimit = 3;
|
| 10 |
this.retryDelay = 1000; // 1s start for exponential backoff
|
server/app.py
CHANGED
|
@@ -182,5 +182,6 @@ def create_app():
|
|
| 182 |
|
| 183 |
if __name__ == '__main__':
|
| 184 |
app = create_app()
|
| 185 |
-
|
| 186 |
-
|
|
|
|
|
|
| 182 |
|
| 183 |
if __name__ == '__main__':
|
| 184 |
app = create_app()
|
| 185 |
+
port = int(os.environ.get("PORT", 7860))
|
| 186 |
+
logger.info(f"Starting DocVault on http://localhost:{port} (DEBUG: {DEBUG})")
|
| 187 |
+
app.run(debug=DEBUG, host='0.0.0.0', port=port)
|