Migrate from Next.js to Flask: Complete motorcycle adventure community website
- Replace Next.js/React implementation with Python Flask - Add colorful blue-purple-teal gradient theme replacing red design - Integrate logo and Transalpina panoramic background image - Implement complete authentication system with Flask-Login - Add community features for stories and tracks sharing - Create responsive design with Tailwind CSS - Add error handling with custom 404/500 pages - Include Docker deployment configuration - Add favicon support and proper SEO structure - Update content for Pensiune BuonGusto accommodation - Remove deprecated Next.js files and dependencies Features: ✅ Landing page with hero section and featured content ✅ User registration and login system ✅ Community section for adventure sharing ✅ Admin panel for content management ✅ Responsive mobile-first design ✅ Docker containerization with PostgreSQL ✅ Email integration with Flask-Mail ✅ Form validation with WTForms ✅ SQLAlchemy database models ✅ Error pages and favicon handling
This commit is contained in:
48
run.py
Normal file
48
run.py
Normal file
@@ -0,0 +1,48 @@
|
||||
import os
|
||||
from app import create_app, db
|
||||
from app.models import User, Post, PostImage, GPXFile, Comment, Like
|
||||
|
||||
app = create_app()
|
||||
|
||||
@app.shell_context_processor
|
||||
def make_shell_context():
|
||||
return {
|
||||
'db': db,
|
||||
'User': User,
|
||||
'Post': Post,
|
||||
'PostImage': PostImage,
|
||||
'GPXFile': GPXFile,
|
||||
'Comment': Comment,
|
||||
'Like': Like
|
||||
}
|
||||
|
||||
@app.cli.command()
|
||||
def init_db():
|
||||
"""Initialize the database."""
|
||||
db.create_all()
|
||||
print('Database initialized.')
|
||||
|
||||
@app.cli.command()
|
||||
def create_admin():
|
||||
"""Create an admin user."""
|
||||
admin_email = os.environ.get('ADMIN_EMAIL', 'admin@moto-adv.com')
|
||||
admin_password = os.environ.get('ADMIN_PASSWORD', 'admin123')
|
||||
|
||||
admin = User.query.filter_by(email=admin_email).first()
|
||||
if admin:
|
||||
print(f'Admin user {admin_email} already exists.')
|
||||
return
|
||||
|
||||
admin = User(
|
||||
nickname='admin',
|
||||
email=admin_email,
|
||||
is_admin=True
|
||||
)
|
||||
admin.set_password(admin_password)
|
||||
|
||||
db.session.add(admin)
|
||||
db.session.commit()
|
||||
print(f'Admin user created: {admin_email}')
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host='0.0.0.0', port=5000, debug=True)
|
||||
Reference in New Issue
Block a user