How do I write my own MVC framework

0 votes
How do I write my own MVC framework?

I want to create my own MVC (Model-View-Controller) framework but don’t know how to start. I understand the basic idea of MVC but need help figuring out how to structure it, manage routes, and connect everything. Can someone explain the steps or give a simple guide on how to build one from scratch?
Oct 21 in Web Development by Nidhi
• 2,660 points
109 views

1 answer to this question.

0 votes

Let’s see what MVC stands for :

  • Modal : Represents the data and logic of the application
  • View : The user interface that displays the data
  • Controller : Handles user input and updates the model and view accordingly

Creating a custom MVC framework can be a rewarding experience, but it’s also a significant undertaking. It requires a deep understanding of design patterns , programming principles , and the specific requirements of your application.

Key Components and Structure

  1. Request Handling :
  • A central dispatcher or router to intercept incoming requests
  • Mapping of URLs to specific controllers and actions
  1. Model :
  • Classes representing data entities
  • Methods for retrieving , creating , updating , and deleting data
  • Consider using database or other data storage mechanism
  1. View :
  • Templates or files that define the UI (e.g., HTML etc.)
  • Placeholders for dynamic content to be filled by the controller
  • Techniques like templating engines
  1. Controller:
  • Handles user requests and interacts with the model and view
  • Receives input , processes it , and updates the model as needed
  • Renders the appropriate view with the updated data
    from flask import Flask, render_template 
    
    app = Flask(__name__)
    
    class User:
    def __init__(self , id , name ):
    self.id = id
    self.name = name 
    
    @app.route('/')
    def index():
    users = [User(1, "Neha"),User (2, "Rohan")]
    return render_template('index.html' , users=users)
    
    if __name__ == '__main__':
    app.run() 
answered Oct 21 by Navya
• 380 points

Related Questions In Web Development

0 votes
0 answers

How do I write my own MVC framework?

How do I write my own MVC ...READ MORE

Oct 14 in Web Development by anonymous
• 2,660 points
41 views
0 votes
1 answer

How can I learn R on my own?

R programming is a language which is developed ...READ MORE

answered Nov 6 in Web Development by kavya
41 views
0 votes
1 answer

How can i create transparency to my images?

The transparency of image can be done ...READ MORE

answered Jan 30, 2020 in Web Development by Niroj
• 82,840 points
812 views
0 votes
1 answer

How do write IF ELSE statement in a MySQL query

You probably want to use a CASE ...READ MORE

answered Feb 18, 2022 in Web Development by Aditya
• 7,680 points
669 views
0 votes
0 answers

How do I send a file from postman to node.js with multer?

How do I send a file from ...READ MORE

Oct 14 in Web Development by anonymous
• 2,660 points
110 views
0 votes
0 answers

How do you implement role-based access control (RBAC) in a full stack application?

How do you implement role-based access control ...READ MORE

Oct 14 in Web Development by anonymous
• 2,660 points
62 views
0 votes
0 answers

How To Implement Caching in Node.js Using Redis?

How To Implement Caching in Node.js Using ...READ MORE

Oct 21 in Web Development by Nidhi
• 2,660 points
76 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How should I implement lazy loading for my images in react?

Imagine you are browsing a website with ...READ MORE

answered Oct 21 in Web Development by Navya
• 380 points
177 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP