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)# 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 objectimport 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__))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)'}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.'''| 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. |
NewerOlder