Spaces:
Runtime error
Runtime error
Download app/__init__.py from lmends/MoneyCouple: direct link, hf CLI and curl.
- Browser
- Download file 2.82 kB
-
https://huggingface.co/spaces/lmends/MoneyCouple/resolve/main/app/__init__.py
- Command line
-
hf download hf://spaces/lmends/MoneyCouple/app/__init__.py
-
curl -L -o __init__.py https://huggingface.co/spaces/lmends/MoneyCouple/resolve/main/app/__init__.py
2.82 kB
| import os | |
| from flask import Flask | |
| from flask_sqlalchemy import SQLAlchemy | |
| from flask_jwt_extended import JWTManager | |
| from flask_cors import CORS | |
| db = SQLAlchemy() | |
| jwt = JWTManager() | |
| def create_app(): | |
| app = Flask(__name__) | |
| app.config.from_object("config.Config") | |
| db.init_app(app) | |
| jwt.init_app(app) | |
| frontend_url = os.environ.get("FRONTEND_URL", "http://localhost:5173") | |
| origins = [o.strip() for o in frontend_url.split(",") if o.strip()] | |
| CORS(app, resources={r"/api/*": {"origins": origins}}, supports_credentials=True) | |
| from app.routes import auth, accounts, transactions, categories, credit_cards, dashboard, budgets, goals, subscriptions, wishlist, analytics, gamification, documents | |
| app.register_blueprint(auth.bp) | |
| app.register_blueprint(accounts.bp) | |
| app.register_blueprint(transactions.bp) | |
| app.register_blueprint(categories.bp) | |
| app.register_blueprint(credit_cards.bp) | |
| app.register_blueprint(dashboard.bp) | |
| app.register_blueprint(budgets.bp) | |
| app.register_blueprint(goals.bp) | |
| app.register_blueprint(subscriptions.bp) | |
| app.register_blueprint(wishlist.bp) | |
| app.register_blueprint(analytics.bp) | |
| app.register_blueprint(gamification.bp) | |
| app.register_blueprint(documents.bp) | |
| with app.app_context(): | |
| from app.models import transaction_audit, goal, goal_yield, subscription, wishlist, document, gamification # noqa: F401 | |
| if os.environ.get("AUTO_CREATE_TABLES", "true").lower() == "true": | |
| db.create_all() | |
| _seed_default_categories() | |
| return app | |
| def _seed_default_categories(): | |
| from app.models.category import Category | |
| if Category.query.count() > 0: | |
| return | |
| defaults = [ | |
| ("Salário", "briefcase", "#22c55e", "income"), | |
| ("Freelance", "laptop", "#10b981", "income"), | |
| ("Investimentos", "trending-up", "#06b6d4", "income"), | |
| ("Outros (receita)", "plus-circle", "#84cc16", "income"), | |
| ("Alimentação", "utensils", "#f97316", "expense"), | |
| ("Mercado", "shopping-cart", "#ef4444", "expense"), | |
| ("Transporte", "car", "#8b5cf6", "expense"), | |
| ("Saúde", "heart", "#ec4899", "expense"), | |
| ("Educação", "book-open", "#3b82f6", "expense"), | |
| ("Lazer", "gamepad-2", "#f59e0b", "expense"), | |
| ("Moradia", "home", "#6366f1", "expense"), | |
| ("Vestuário", "shirt", "#a855f7", "expense"), | |
| ("Assinaturas", "repeat", "#14b8a6", "expense"), | |
| ("Delivery", "package", "#fb923c", "expense"), | |
| ("Pets", "paw-print", "#e879f9", "expense"), | |
| ("Outros (despesa)", "minus-circle", "#94a3b8", "expense"), | |
| ] | |
| for name, icon, color, type_ in defaults: | |
| cat = Category(name=name, icon=icon, color=color, type=type_, is_shared=True) | |
| db.session.add(cat) | |
| db.session.commit() | |