Ejemplo n.º 1
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])

    api = Api(app)

    api.add_resource(User, '/api/user/<string:name>')
    api.add_resource(Users, '/api/users/')

    db.init_app(app)
    ma.init_app(app)

    with app.app_context():
        db.create_all()

    return app
Ejemplo n.º 2
0
Archivo: app.py Proyecto: Mox93/rizzmi
 def create_tables():
     db.create_all()
Ejemplo n.º 3
0
def create_db():
    db.create_all()
Ejemplo n.º 4
0
import os
from dotenv import load_dotenv
from flask import Flask
from flask_restful import Resource, Api
from common.db import db
from models import *
import resources

load_dotenv()

app = Flask(__name__)
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
app.config["SQLALCHEMY_DATABASE_URI"] = os.getenv("POSTGRES_CONNECTION_STRING")
api = Api(app)
db.init_app(app)

# Auth
api.add_resource(resources.Register, "/auth/register")
api.add_resource(resources.Login, "/auth/login")

# Boards
api.add_resource(resources.Boards, "/api/boards")

if __name__ == "__main__":
    print("Building database schema")
    with app.app_context():
        db.create_all()

    app.run(debug=True)
def create_tables():
    """
    Intiailize data.db automatically
    :return: none, data.db created in root
    """
    db.create_all()