Esempio n. 1
0
def safe_pool(method, data):
    cfg.cur.close()

    pool = Pool(processes=cfg.available_cpus)
    result = pool.map(method, data)
    pool.close()
    pool.join()

    cfg.init_db()
    return result
Esempio n. 2
0
from flask import Flask
from config import db_session, init_db
from flask_graphql import GraphQLView
from schema import schema
from flask_cors import CORS

app = Flask(__name__)
app.debug = True
CORS(app)

app.add_url_rule('/graphql',
                 view_func=GraphQLView.as_view('graphql',
                                               schema=schema,
                                               graphiql=True))


@app.teardown_appcontext
def shutdown_session(exception=None):
    db_session.remove()


if __name__ == '__main__':
    init_db()
    app.run(host='0.0.0.0')
Esempio n. 3
0
		sqlstring = "DROP TABLE IF EXISTS "+ tob.table+" CASCADE;\n"
	
	sqlstring += "create table %s (" % tableDef.table 
	sqlstring += ", ".join(cols)
	sqlstring = sqlstring + ");\n"
	return sqlstring


	
##======================================================================
## Lets GO!
##======================================================================

## import config and connect db
import config
config.init_db(opts.connect_yaml)

## Load yaml with table def
table_def_yaml = args[0]
tob = config.load_yaml(table_def_yaml, as_object=True)
#print tob, tob.table

## Create the table
sql =  get_create_table_sql(tob, drop=True)
config.DB.execute(sql)
config.CONN.commit()

# All done
config.CONN.close()

print "--- CREATED TABLE: %s ---" % tob.table
Esempio n. 4
0
    if request.method == 'POST':
        email = escape(request.form['email'])
        username = escape(request.form['username'])
        password = escape(request.form['password'])
        hashed = util.secure_md5_hashing(password)
        if not qry.user_exists(username):
            registered = qry.register_account(username, email, hashed)
            if registered:
                flash('You were successfully registered', 'success')
                resp = app.make_response(redirect(url_for('hello')))
                resp.set_cookie('username', value=username)
                resp.set_cookie('logged_in', value='1')
                return resp
            else:
                error = 'Something went wrong when registring your account'
        else:
            error = 'The cyberspace is not big enough for the both of you...'

    return render_template('register.html', error=error)

#################

@app.errorhandler(404)
def page_not_found(error):
    return render_template('404.html'), 404


if __name__ == '__main__':
    config.init_db()
    app.run(host="0.0.0.0")
Esempio n. 5
0
def setup():
    """Initializes the sqlite3 database used in development."""
    if not os.path.isfile(os.path.join(DIRECTORY, 'test.db')):
        init_db()
Esempio n. 6
0
from bottle import Bottle

from datafly.core import merge, template, init_globals, debug, log_errors

from config import Config, init_db
from views.hooks import before_request

init_db()

### Main Application

app = Bottle()

@app.error(404)
def page404(code):
    return template('404.html')


### Import & configure modules

# /<page>
merge(app, 'views.public:public')

# /blog/<page>
merge(app, 'datafly.views.blog:public',
    config = {
        'feed': {            
            'title': 'Blog',
            'desc': 'Blog about ...',
            'email': '*****@*****.**',
            'author': 'DataFly'
Esempio n. 7
0
from flask import Flask
import config
import sys
from model.user import User
from model.credencial import Credencial
from model.orden_canje import Orden_canje
from model.producto import Producto
from model.orden_producto import Orden_producto

app = Flask(__name__, instance_relative_config=True)

#config
app.config.from_object('config')

# Si para levantar el server le pasamos createdb entonces dropea la BD y la crea de nuevo.
if len(sys.argv) > 1 and 'createdb' == sys.argv[1]:
    config.drop_db()
    config.init_db(True)
else:
    config.init_db(False)

if __name__ == '__main__':
    app.run('0.0.0.0', port=5000)