File size: 2,715 Bytes
17847d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Deploying to Hugging Face Spaces - Correct Method

## The Problem

Hugging Face Spaces rejects binary files and development files like:
- `.venv/` (virtual environment)
- `node_modules/`
- Database files (`.db`, `.sqlite`)
- User-uploaded images

## Solution: Copy Only Required Files

**Don't push your entire backend directory!** Only copy the files needed for deployment.

## Step-by-Step Instructions

### 1. Clone the Space Repository

```bash
git clone https://huggingface.co/spaces/FireBird-Tech/autoform-backend
cd autoform-backend
```

### 2. Copy ONLY Required Files

Copy only these files (NOT the entire backend directory):

```bash
# From your project root
cd autoform-backend

# Copy Dockerfile
cp ../backend/Dockerfile .

# Copy requirements
cp ../backend/requirements.txt .

# Copy application code (this excludes venv, db files, etc.)
cp -r ../backend/app .

# Copy ONLY logo images (not user-uploaded content)
mkdir -p images
cp ../backend/images/AutoForm.png images/
cp ../backend/images/AutoForm.svg images/
cp ../backend/images/favicon.png images/
```

### 3. Create README.md

Create `README.md` in the Space root:

```markdown
---
title: AutoForm Backend API
emoji: πŸ“
colorFrom: purple
colorTo: pink
sdk: docker
sdk_version: 4.0.0
app_port: 7860
---

# AutoForm Backend API

FastAPI backend for AutoForm.
```

### 4. Verify Files

Make sure you DON'T have:
- ❌ `.venv/` directory
- ❌ `venv/` directory
- ❌ `node_modules/` directory
- ❌ `*.db` files
- ❌ `chat.db`
- ❌ User-uploaded images (keep only logos)

You SHOULD have:
- βœ… `Dockerfile`
- βœ… `requirements.txt`
- βœ… `app/` directory (with Python code)
- βœ… `images/` directory (with only logo files)
- βœ… `README.md`

### 5. Commit and Push

```bash
git add Dockerfile requirements.txt app/ images/ README.md
git commit -m "Add AutoForm backend"
git push
```

## What Files to Include

**Include:**
- `Dockerfile`
- `requirements.txt`
- `app/` directory (all Python source files)
- `images/AutoForm.png`
- `images/AutoForm.svg`
- `images/favicon.png`

**Exclude:**
- `.venv/` or `venv/`
- `node_modules/`
- `*.db` files
- `chat.db`
- User-uploaded images (anything in `images/` that's not a logo)
- `__pycache__/` directories
- `.env` files

## Quick Copy Script

Create a script to copy only the right files:

```bash
#!/bin/bash
# copy_to_hf.sh

HF_DIR="../autoform-backend"  # Adjust path as needed

# Copy essential files
cp Dockerfile "$HF_DIR/"
cp requirements.txt "$HF_DIR/"
cp -r app "$HF_DIR/"

# Copy only logo images
mkdir -p "$HF_DIR/images"
cp images/AutoForm.png "$HF_DIR/images/"
cp images/AutoForm.svg "$HF_DIR/images/"
cp images/favicon.png "$HF_DIR/images/"

echo "Files copied successfully!"
```