Exemplo n.º 1
0
from flask import Flask, send_file, make_response, redirect, request
from ezmysql import TableDef
from configfile import ConfigFile
from requests import post as http_post

CONFIG = ConfigFile('./itapps.cfg')

DB_server = CONFIG.Get('DBServer')
DB_user = CONFIG.Get('DBUser')
DB_password = CONFIG.Get('DBPassword')
TABLES = Config.Get('DBTables').split(',')

# Configure table objects
TABLES = [{"name" : a,"def" : TableDef(DB_server,DB_user,DB_password,a)} for a in TABLES]

# Pull schema
for thisTable in DB_tables:
  thisTable['schema'] = thisTable['def'].Schema()

ROOT = '/var/www/python/dbedit'

app = Flask(__name__)

@app.route('/')
def getroot():
  return render_template('{}/templates/show_tables.html'.format(ROOT),tables=[a['name'] for a in DB_tables])

@app.routes('/<table>/list')
def TableList(table):
  tableAr = [a for a in DB_tables if a['name'] == table]
  if len(tableAr) == 1: