newBlog / new.py
mistpe's picture
Upload 4 files
615cbcf verified
raw
history blame
2.06 kB
# 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()