Example #1
0
from dbutils import MONGO_URI
from dbutils import db_connect
from dbutils import db_insert_user
from dbutils import db_find_all
from form import BuyForm
from form import LoginForm
from flask import Flask
from flask import request
from flask import render_template

app = Flask(__name__)
users = db_connect(MONGO_URI, 'Proyecto_Madero', 'users')


@app.route('/admin', methods=['GET', 'POST'])
def index():
    form = BuyForm(request.form)
    flag = False
    name = None

    if len(form.errors):
        print(form.errors)
    if request.method == 'POST':
        item = form.item.data
        precio = form.precio.data
        if item != '' and precio != '':
            print(f"Nombre capturado: {item}")
            print(f"Email capturado: {precio}")
            user = {"item": item, "precio": precio}
            db_insert_user(users, user)
            flag = True
Example #2
0
from dbutils import MONGO_URI
from dbutils import db_connect
from dbutils import db_insert_user
from dbutils import db_find_all
from form import EmailForm
from form import LoginForm
from flask import Flask
from flask import request
from flask import render_template

app = Flask(__name__)
users = db_connect(MONGO_URI, 'mi_app', 'users')

#@app.route('/tables')
#def tables():
#    return render_template('tables.html')


@app.route('/', methods=['GET', 'POST'])
def index():
    form = EmailForm(request.form)
    flag = False
    name = None

    if len(form.errors):
        print(form.errors)
    if request.method == 'POST':
        email = form.email.data
        name = form.name.data
        if email != '' and name != '':
            print(f"Nombre capturado: {name}")
Example #3
0
from form import RegisterForm
from form import VoluntariadoForm
from form import ReporteForm
from config import Config
from flask import Flask
from flask import request
from flask import render_template
from flask_mail import Mail
from flask_mail import Message

# Creacion de instance
app = Flask(__name__)
mail = Mail()

# Inserta en la colletion de Usuarios / Registro
users = db_connect(MONGO_URI, 'mi_app', 'users')

# Inserta en colletion de Voluntariado / Voluntariado
voluntariados = db_connect(MONGO_URI, 'mi_app', 'voluntariados')

# Inserta en colletion de Reporte / reporte
reportes = db_connect(MONGO_URI, 'mi_app', 'reporte')


@app.route('/', methods=['GET', 'POST'])
def index():
    form = LoginForm(request.form)
    login_error = False
    if len(form.errors):
        print(form.errors)
    if request.method == 'POST':
Example #4
0
from dbutils import MONGO_URI
from dbutils import db_connect
from dbutils import db_insert_user
from dbutils import db_find_all
from form import EmailForm
from form import LoginForm
from flask import Flask
from flask import request
from flask import render_template


app = Flask(__name__)

#CCreating collections called users
users = db_connect(MONGO_URI,"mi_app",'users')


#@app.route('/tables')
#def tables():
#    return render_template('tables.html')


@app.route('/', methods=['GET', 'POST'])
def index():
    form = EmailForm(request.form)
    flag = False
    name = None

    if len(form.errors):
        print(form.errors)
    if request.method == 'POST':
Example #5
0
from form import EmailForm
from form import LoginForm
from flask import Flask
from flask import request
from flask import render_template
from dbutils import db_connect
from dbutils import db_insert_user
from dbutils import db_find_all
from dbutils import MONGO_URL

app = Flask(__name__)
users = db_connect(MONGO_URL, "mi_app", "users")


@app.route('/', methods=['GET', 'POST'])
def index():
    form = EmailForm(request.form)
    flag = False
    name = None

    if len(form.errors):
        print(form.errors)
    if request.method == 'POST':
        email = form.email.data
        name = form.name.data
        if email != '' and name != '':
            print(f"Nombre capturado: {name}")
            print(f"Email capturado: {email}")
            user = {"name": name, "email": email}
            r = db_insert_user(users, user)
            print("Insercion: ", r)
Example #6
0
#/usr/bin/env python3
from dbutils import db_connect
import sqlite3
import os
import sys
conn = db_connect("db_router.sqlite3")
#INSERT VALUE into TABLE
try:
    conn.execute(
        "INSERT INTO INVENTORY (IP,LOCATION,BRAND,USERNAME,PASSWORD) VALUES ('10.10.10.10', 'Medan', 'Cisco', 'admin', 'admin')"
    )
    conn.execute(
        "INSERT INTO INVENTORY (IP,LOCATION,BRAND,USERNAME,PASSWORD) VALUES ('10.10.10.20', 'Medan', 'Juniper', 'admin', 'admin123')"
    )
    conn.execute(
        "INSERT INTO INVENTORY (IP,LOCATION,BRAND,USERNAME,PASSWORD) VALUES ('10.10.10.30', 'Medan', 'Brocade', 'admin', 'admin321')"
    )
    conn.execute(
        "INSERT INTO INVENTORY (IP,LOCATION,BRAND,USERNAME,PASSWORD) VALUES ('10.10.10.40', 'Jakarta', 'HuaWei', 'huawei', 'china')"
    )
    conn.commit()
except:
    print("Can't Insert Records into INVENTORY Table")
    sys.exit(1)
print("Records created successfully")
#SELECT and print the records
try:
    cursor = conn.execute(
        "SELECT IP, LOCATION, BRAND, USERNAME, PASSWORD from INVENTORY")
    for row in cursor:
        print("IP = ", row[0])