Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Flask-based web application following the MVC (Model-View-Controller) structure, with the added feature of integrating a Discord bot. The structure is flexible, allowing you to expand it for more parallel tasks, or easily adjust it to run a single task as needed.

License

NotificationsYou must be signed in to change notification settings

zaber-dev/MVC-Python

Repository files navigation

Welcome to theFlask MVC Structure with Discord Integration! This project is primarily aFlask-based web application following the MVC (Model-View-Controller) structure, with the added feature of integrating aDiscord bot usingDisnake. This setup allows you to build a web app while also having a Discord bot running in parallel, enabling additional functionality. The structure is flexible, allowing you to expand it for more parallel tasks, or easily adjust it to run a single task as needed.

Project Structure

.├── app│   ├── Actions# Utility functions (pagination, embeds, webhook handling, etc.)│   ├── Commands# Discord command handling│   │   ├── Context# Traditional Discord commands│   │   └── Slash# Slash commands for Discord│   ├── Controllers# Controller logic for Flask and Discord│   │   ├── Flask# Controllers specific to Flask web app│   │   └── Discord# Controllers for Discord bot│   ├── Models# Data models for the application│   └── Views# Dynamic Flask views/templates structures├── config│   └── boot.py# Main entry point to boot up the program (Flask + Discord)├── database│   └── db.py# Database interactions (abstraction layer)├── resources# Static and template files for Flask│   ├── css# CSS files│   ├── js# JavaScript files│   └── views# HTML templates├── routes│   ├── api.py# Routes for API endpoints│   └── web.py# Routes for web pages├── storage# User file storage (uploads, etc.)├── vendor# Placeholder for third-party integrations (collaborations welcome)├── requirements.txt# Python dependencies├── Dockerfile# Docker containerization file└── .env# Environment configuration variables

Features Implemented

Flask

  • MVC Structure: Organized codebase that follows the MVC pattern for better separation of concerns:
    • Models handle data.
    • Views are rendered by Flask, found inresources/views.
    • Controllers handle business logic for web and API routes.
  • Routing:
    • API routes are defined inroutes/api.py.
    • Web routes are inroutes/web.py.
  • Database Abstraction: Easy-to-extend database layer (database/db.py) for managing models.
  • Templates & Static Files: Resources such as HTML, CSS, and JavaScript are stored inresources/.

Discord Bot (Using Discord.py)

  • Commands:
    • Traditional text-based Discord commands inapp/Commands/Context.
    • Slash commands inapp/Commands/Slash.
  • Parallel Execution: The Discord bot runs alongside the Flask application for seamless interaction between web and Discord functionalities.
  • Utility Actions: Functions like pagination, embeds, and webhook handling inapp/Actions.

Docker

  • Containerization: ProvidedDockerfile allows you to run the entire application in a Docker container, simplifying the setup process.

What's Next?

To-Do

  • Vendor Integrations: Open for contributions to implement third-party integrations or plugins within thevendor/ directory.
  • Authentication: Integrate authentication (OAuth or token-based) for the web app and APIs.
  • File Management: Add advanced handling for user uploads within thestorage/ folder.
  • Error Handling & Logging: Enhance error handling across both Flask and Discord components, with proper logging.

Collaboration

Contributions are welcome! If you'd like to collaborate, feel free to fork this repository and submit a pull request. Potential areas of contribution include:

  • Implementing additional Flask features.
  • Expanding Discord bot functionalities (commands, event listeners, etc.).
  • Integrating new third-party APIs or services.
  • Improving the MVC structures

Check out theissues section for current needs, or suggest your own enhancements!

Getting Started

  1. Clone the Repository:

    git clone https://github.com/MahediZaber51/MVC-Python.gitcd MVC-Python
  2. Install Dependencies:

    pip install -r requirements.txt
  3. Set up Environment Variables:Create a.env file in the root directory with the required environment variables for Flask and Discord (check the.env-example file).

  4. Run the Application:

    python config/boot.py
  5. Run in Docker:

    docker build -t flask-discord-app.docker run -d -p 5000:5000 flask-discord-app

License

This project is licensed under the GNU General Public License v3.0.

About

Flask-based web application following the MVC (Model-View-Controller) structure, with the added feature of integrating a Discord bot. The structure is flexible, allowing you to expand it for more parallel tasks, or easily adjust it to run a single task as needed.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp