File size: 2,351 Bytes
ad813fc
 
 
 
 
 
 
 
 
 
 
 
 
45cf072
ad813fc
 
 
 
 
 
 
45cf072
ad813fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45cf072
ad813fc
 
45cf072
 
ad813fc
 
45cf072
ad813fc
 
45cf072
 
ad813fc
 
45cf072
 
 
ad813fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45cf072
ad813fc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
---
title: Time Card Generator
emoji: ⏱️
colorFrom: green
colorTo: blue
sdk: streamlit
sdk_version: 1.37.0
app_file: app.py
pinned: false
---

# Time Card Generator

A Streamlit application for creating, editing, and saving shift cards to Firebase Realtime Database through simple HTTP requests. The UI is optimized for Hugging Face Streamlit Spaces and does not require Google Apps Script.

## Features

- Add unlimited time cards
- Edit title and start time inline
- Automatically calculate end time as `+2 hours`
- Save new cards and update existing cards
- Delete cards locally or from Firebase
- Load saved cards automatically on startup
- Use `st.session_state` for responsive card management

## Project Structure

```text
streamlit_app/
├── app.py
├── requirements.txt
├── README.md
├── .gitignore
├── assets/
│   └── style.css
├── components/
│   ├── buttons.py
│   ├── card.py
│   └── header.py
├── services/
│   └── api.py
├── utils/
│   └── time_utils.py
└── .streamlit/
    └── secrets.toml.example
```

## Configuration

Create `.streamlit/secrets.toml` from the example file:

```toml
FIREBASE_DATABASE_URL="https://smartedu-3d5bf-default-rtdb.firebaseio.com"
FIREBASE_AUTH_TOKEN=""
```

This repository is already configured with the Firebase Realtime Database URL in `.streamlit/secrets.toml`:

```toml
FIREBASE_DATABASE_URL="https://smartedu-3d5bf-default-rtdb.firebaseio.com"
FIREBASE_AUTH_TOKEN=""
```

Notes:
- Leave `FIREBASE_AUTH_TOKEN` empty if your Realtime Database rules allow direct access.
- If your database rules require authentication, add a valid Firebase Database auth token there or as a Hugging Face Space secret.

## Run Locally

```bash
cd streamlit_app
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
streamlit run app.py
```

## Deploy to Hugging Face Streamlit Space

1. Create a new Hugging Face Space.
2. Choose `Streamlit` as the SDK.
3. Upload the contents of `streamlit_app/`.
4. This repo can run without extra edits because `.streamlit/secrets.toml` is included.
5. Optionally, add Hugging Face Space secrets named `FIREBASE_DATABASE_URL` and `FIREBASE_AUTH_TOKEN` if you prefer managing them outside the repo.
6. Commit and let the Space build automatically.