Skip to content

Instantly share code, notes, and snippets.

View arslandevs's full-sized avatar
:octocat:
Bravo !

Syed Arsalan Amin arslandevs

:octocat:
Bravo !
View GitHub Profile
@arslandevs
arslandevs / blueprint_flask_mvc.md
Created December 12, 2021 20:30
blueprint for flask mvc
from flask import Blueprint
from controllers.machineController import index, create, insert

blueprint = Blueprint('blueprint', __name__)

blueprint.route('/', methods=['GET'])(index)
blueprint.route('/create', methods=['GET'])(create)
blueprint.route('/insert', methods=['GET'])(insert)
@arslandevs
arslandevs / app_flask_mvc.md
Created December 12, 2021 20:07
app file for flask mvc
# Importing the necessary modules and libraries
from flask import Flask
from flask_migrate import Migrate
from routes.blueprint import blueprint
from models.machine import db


def create_app():
 app = Flask(__name__) # flask app object
@arslandevs
arslandevs / config_flask_mvc.md
Created December 12, 2021 20:04
config file for mysql database flask mvc
import os

# Each Flask web application contains a secret key which used to sign session cookies for protection against cookie data tampering.
SECRET_KEY = os.urandom(32)

# Grabs the folder where the script runs.
# In my case it is, "F:\DataScience_Ai\hobby_projects\mvc_project\src"
basedir = os.path.abspath(os.path.dirname(__file__))
@arslandevs
arslandevs / controller_flask_mvc.md
Last active December 15, 2021 20:58
controller for flask mvc
import json
from models.machine import Inserttable, db
from services.user_service import insert_logic, create_logic

def index():
    return {'status': 'OK',
            'localhost:5000/machines/create': 'Create table in mysql database',
            'localhost:5000/machines/insert': 'Insert data in mysql database table(Inserttable)'}
@arslandevs
arslandevs / Flask_model_mvc.md
Created December 12, 2021 19:58
Flask_model_mvc
from flask_sqlalchemy import SQLAlchemy

db = SQLAlchemy()

# Creating the Inserttable for inserting data into the database


class Inserttable(db.Model):
 '''Data for ON/OFF should be dumped in this table.'''
@arslandevs
arslandevs / table_flask_env_variable.md
Created December 12, 2021 19:52
flask environment variables table
Environment Variable Description
set FLASK_ENV=development Tell that we are on development environment.
set FLASK_APP=app Tells the server to detect our app.
flask run Start our app.