Spaces:
Sleeping
Sleeping
raymondEDS
commited on
Commit
Β·
05152ad
1
Parent(s):
4e16788
fixing
Browse files- README.md +23 -6
- src/streamlit_app.py +26 -37
README.md
CHANGED
|
@@ -16,7 +16,7 @@ short_description: LMS with login and PDF upload
|
|
| 16 |
|
| 17 |
# Dev LMS - Learning Management System
|
| 18 |
|
| 19 |
-
A comprehensive Learning Management System built with Streamlit that provides user authentication and PDF document management capabilities.
|
| 20 |
|
| 21 |
## π Features
|
| 22 |
|
|
@@ -31,6 +31,7 @@ A comprehensive Learning Management System built with Streamlit that provides us
|
|
| 31 |
- Text extraction from PDF files
|
| 32 |
- Document preview and search functionality
|
| 33 |
- Document library with user ownership tracking
|
|
|
|
| 34 |
|
| 35 |
### π Dashboard
|
| 36 |
- User activity metrics
|
|
@@ -56,6 +57,7 @@ The system comes with three default user accounts:
|
|
| 56 |
|
| 57 |
## π οΈ Installation & Usage
|
| 58 |
|
|
|
|
| 59 |
1. **Install Dependencies:**
|
| 60 |
```bash
|
| 61 |
pip install -r requirements.txt
|
|
@@ -65,21 +67,28 @@ The system comes with three default user accounts:
|
|
| 65 |
```bash
|
| 66 |
streamlit run src/streamlit_app.py
|
| 67 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
3. **Access the Application:**
|
| 70 |
- Open your browser and go to `http://localhost:8501`
|
| 71 |
- Login with one of the default credentials
|
| 72 |
- Start uploading and managing PDF documents!
|
| 73 |
|
|
|
|
|
|
|
|
|
|
| 74 |
## π Application Structure
|
| 75 |
|
| 76 |
```
|
| 77 |
βββ src/
|
| 78 |
β βββ streamlit_app.py # Main application file
|
| 79 |
-
βββ
|
| 80 |
-
β
|
| 81 |
-
β βββ users/ # User configuration
|
| 82 |
βββ requirements.txt # Python dependencies
|
|
|
|
| 83 |
βββ README.md # This file
|
| 84 |
```
|
| 85 |
|
|
@@ -88,8 +97,9 @@ The system comes with three default user accounts:
|
|
| 88 |
- **Framework:** Streamlit
|
| 89 |
- **Authentication:** streamlit-authenticator
|
| 90 |
- **PDF Processing:** PyPDF2
|
| 91 |
-
- **Data Storage:** Session state
|
| 92 |
- **Security:** bcrypt password hashing
|
|
|
|
| 93 |
|
| 94 |
## π― Use Cases
|
| 95 |
|
|
@@ -106,6 +116,13 @@ The system comes with three default user accounts:
|
|
| 106 |
- Document ownership tracking
|
| 107 |
- Secure file upload handling
|
| 108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
## π Future Enhancements
|
| 110 |
|
| 111 |
- Database integration for persistent storage
|
|
@@ -117,4 +134,4 @@ The system comes with three default user accounts:
|
|
| 117 |
|
| 118 |
---
|
| 119 |
|
| 120 |
-
**Built with β€οΈ using Streamlit**
|
|
|
|
| 16 |
|
| 17 |
# Dev LMS - Learning Management System
|
| 18 |
|
| 19 |
+
A comprehensive Learning Management System built with Streamlit that provides user authentication and PDF document management capabilities. **Cloud-ready and optimized for Hugging Face Spaces deployment.**
|
| 20 |
|
| 21 |
## π Features
|
| 22 |
|
|
|
|
| 31 |
- Text extraction from PDF files
|
| 32 |
- Document preview and search functionality
|
| 33 |
- Document library with user ownership tracking
|
| 34 |
+
- **Cloud-ready storage using session state**
|
| 35 |
|
| 36 |
### π Dashboard
|
| 37 |
- User activity metrics
|
|
|
|
| 57 |
|
| 58 |
## π οΈ Installation & Usage
|
| 59 |
|
| 60 |
+
### Local Development
|
| 61 |
1. **Install Dependencies:**
|
| 62 |
```bash
|
| 63 |
pip install -r requirements.txt
|
|
|
|
| 67 |
```bash
|
| 68 |
streamlit run src/streamlit_app.py
|
| 69 |
```
|
| 70 |
+
Or use the convenient startup script:
|
| 71 |
+
```bash
|
| 72 |
+
python run_app.py
|
| 73 |
+
```
|
| 74 |
|
| 75 |
3. **Access the Application:**
|
| 76 |
- Open your browser and go to `http://localhost:8501`
|
| 77 |
- Login with one of the default credentials
|
| 78 |
- Start uploading and managing PDF documents!
|
| 79 |
|
| 80 |
+
### Cloud Deployment
|
| 81 |
+
The application is optimized for deployment on Hugging Face Spaces and other cloud platforms. No file system permissions required - all data is stored in session state.
|
| 82 |
+
|
| 83 |
## π Application Structure
|
| 84 |
|
| 85 |
```
|
| 86 |
βββ src/
|
| 87 |
β βββ streamlit_app.py # Main application file
|
| 88 |
+
βββ .streamlit/
|
| 89 |
+
β βββ config.toml # Streamlit configuration
|
|
|
|
| 90 |
βββ requirements.txt # Python dependencies
|
| 91 |
+
βββ run_app.py # Startup script
|
| 92 |
βββ README.md # This file
|
| 93 |
```
|
| 94 |
|
|
|
|
| 97 |
- **Framework:** Streamlit
|
| 98 |
- **Authentication:** streamlit-authenticator
|
| 99 |
- **PDF Processing:** PyPDF2
|
| 100 |
+
- **Data Storage:** Session state (cloud-ready)
|
| 101 |
- **Security:** bcrypt password hashing
|
| 102 |
+
- **Deployment:** Optimized for Hugging Face Spaces
|
| 103 |
|
| 104 |
## π― Use Cases
|
| 105 |
|
|
|
|
| 116 |
- Document ownership tracking
|
| 117 |
- Secure file upload handling
|
| 118 |
|
| 119 |
+
## βοΈ Cloud Features
|
| 120 |
+
|
| 121 |
+
- **No file system dependencies** - works on read-only environments
|
| 122 |
+
- **Session-based storage** - data persists during user session
|
| 123 |
+
- **Optimized for Hugging Face Spaces** - ready for immediate deployment
|
| 124 |
+
- **Lightweight and fast** - minimal resource requirements
|
| 125 |
+
|
| 126 |
## π Future Enhancements
|
| 127 |
|
| 128 |
- Database integration for persistent storage
|
|
|
|
| 134 |
|
| 135 |
---
|
| 136 |
|
| 137 |
+
**Built with β€οΈ using Streamlit | Cloud-ready for Hugging Face Spaces**
|
src/streamlit_app.py
CHANGED
|
@@ -24,50 +24,39 @@ if 'username' not in st.session_state:
|
|
| 24 |
st.session_state.username = None
|
| 25 |
if 'uploaded_documents' not in st.session_state:
|
| 26 |
st.session_state.uploaded_documents = {}
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
os.makedirs('data', exist_ok=True)
|
| 30 |
-
os.makedirs('data/documents', exist_ok=True)
|
| 31 |
-
os.makedirs('data/users', exist_ok=True)
|
| 32 |
-
|
| 33 |
-
# User configuration file
|
| 34 |
-
USERS_FILE = 'data/users/users.yaml'
|
| 35 |
|
| 36 |
def create_default_users():
|
| 37 |
-
"""Create default users
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
'
|
| 41 |
-
'
|
| 42 |
-
'
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
'
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
'
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
'password': stauth.Hasher(['student123']).generate()[0]
|
| 56 |
-
}
|
| 57 |
}
|
| 58 |
}
|
| 59 |
}
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
with open(USERS_FILE, 'w') as file:
|
| 63 |
-
yaml.dump(default_users, file, default_flow_style=False)
|
| 64 |
|
| 65 |
def load_users():
|
| 66 |
-
"""Load users
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
return config
|
| 71 |
|
| 72 |
def save_document_info(username, filename, file_content, file_type):
|
| 73 |
"""Save document information to session state"""
|
|
|
|
| 24 |
st.session_state.username = None
|
| 25 |
if 'uploaded_documents' not in st.session_state:
|
| 26 |
st.session_state.uploaded_documents = {}
|
| 27 |
+
if 'users_config' not in st.session_state:
|
| 28 |
+
st.session_state.users_config = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
def create_default_users():
|
| 31 |
+
"""Create default users configuration"""
|
| 32 |
+
default_users = {
|
| 33 |
+
'credentials': {
|
| 34 |
+
'usernames': {
|
| 35 |
+
'admin': {
|
| 36 |
+
'email': 'admin@example.com',
|
| 37 |
+
'name': 'Administrator',
|
| 38 |
+
'password': stauth.Hasher(['admin123']).generate()[0]
|
| 39 |
+
},
|
| 40 |
+
'teacher': {
|
| 41 |
+
'email': 'teacher@example.com',
|
| 42 |
+
'name': 'Teacher',
|
| 43 |
+
'password': stauth.Hasher(['teacher123']).generate()[0]
|
| 44 |
+
},
|
| 45 |
+
'student': {
|
| 46 |
+
'email': 'student@example.com',
|
| 47 |
+
'name': 'Student',
|
| 48 |
+
'password': stauth.Hasher(['student123']).generate()[0]
|
|
|
|
|
|
|
| 49 |
}
|
| 50 |
}
|
| 51 |
}
|
| 52 |
+
}
|
| 53 |
+
return default_users
|
|
|
|
|
|
|
| 54 |
|
| 55 |
def load_users():
|
| 56 |
+
"""Load users configuration"""
|
| 57 |
+
if st.session_state.users_config is None:
|
| 58 |
+
st.session_state.users_config = create_default_users()
|
| 59 |
+
return st.session_state.users_config
|
|
|
|
| 60 |
|
| 61 |
def save_document_info(username, filename, file_content, file_type):
|
| 62 |
"""Save document information to session state"""
|