File size: 2,060 Bytes
615cbcf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# setup_project.py
import os

def create_directory_structure():
    # Define the project structure
    structure = {
        'app': {
            'static': {
                'css': {},
                'js': {},
                'img': {},
                'uploads': {}
            },
            'templates': {
                'admin': {},
                'components': {}
            },
            'database': {},
        }
    }

    # Define files to create
    files = [
        'app/__init__.py',
        'app/routes.py',
        'app/models.py',
        'app/utils.py',
        'app/ai_service.py',
        'app/templates/base.html',
        'app/templates/index.html',
        'app/templates/article.html',
        'app/templates/editor.html',
        'app/templates/admin/login.html',
        'app/templates/admin/dashboard.html',
        'app/templates/components/header.html',
        'app/templates/components/footer.html',
        'app/static/css/style.css',
        'app/static/js/editor.js',
        'app/static/js/main.js',
        '.env.example',
        'config.py',
        'run.py',
        'requirements.txt'
    ]

    def create_directories(base_path, structure):
        for key, value in structure.items():
            path = os.path.join(base_path, key)
            os.makedirs(path, exist_ok=True)
            if isinstance(value, dict):
                create_directories(path, value)

    # Create directories
    create_directories('.', structure)

    # Create empty files
    for file_path in files:
        open(file_path, 'a').close()

    # Create .env.example with template content
    env_content = """FLASK_ENV=development

FLASK_SECRET_KEY=your-secret-key

ADMIN_USERNAME=admin

ADMIN_PASSWORD=password

AI_API_KEY=your-api-key

AI_BASE_URL=https://api.deepseek.com"""

    with open('.env.example', 'w') as f:
        f.write(env_content)

    print("Project structure created successfully!")

if __name__ == "__main__":
    create_directory_structure()