예제 #1
0
def create_db():
    with create_app().app_context():
        from models.user import User
        db.create_all()
예제 #2
0
            if not task:
                return abort(404)
            if request.method == 'POST':
                name = request.form.get('name')
                if not name:
                    return abort(404)
                quest = Questionnaire(name=name, task=task)
                task.questionnaires.append(quest)
                for key, value in request.form.items():
                    if not value or key == 'name':
                        continue
                    else:
                        quest.questions.append(
                            Question(text=value, questionnaire=quest))
                db.session.commit()
        return render_template('newQuestionnaire.html')

    @app.route('/logout', methods=['GET'])
    def logout():
        session.pop('auth')
        return redirect(url_for('index'))

    return app


if __name__ == '__main__':
    app = create_app()
    db.create_all(app=app)
    app.run(host='localhost', port=3000, debug=True)
예제 #3
0
def db_setup():
    db.create_all()
예제 #4
0
from flask_modus import Modus

from models.shared import db
from models.author import Author
from models.book import Book

app = Flask(__name__)
modus = Modus(app)

app.config[
    'SQLALCHEMY_DATABASE_URI'] = 'postgres://localhost/library_flask_app'

app.url_map.strict_slashes = False
db.init_app(app)
with app.app_context():
    db.create_all()


@app.route('/')
def root():
    return render_template('index.html')


@app.route('/authors')
def authors_index():
    return render_template('authors/index.html', authors=Author.query.all())


@app.route('/authors/new')
def authors_new():
    return render_template('authors/new.html')
예제 #5
0
def db_setup():
    db.create_all()
예제 #6
0
 def setUp(self):
     db.create_all()
예제 #7
0
파일: main.py 프로젝트: czhanacek/petdoor
# the base urls for each set of applications
collar = "/collar/"
web = "/web/"


def create_app():
    app = Flask(__name__)
    CORS(app)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///petdoor.db'
    db.init_app(app)
    return app


app = create_app()
app.app_context().push()
db.create_all()  # the order of this and the previous 2 lines is important


def timestamp():
    return calendar.timegm(time.gmtime()) * 1000


def validatePasscode(request):
    passcode = request.form.get("passcode", None)
    if (passcode != systemstats.passcode):
        return False
    else:
        return True


def mapStatusToState(status):
예제 #8
0
from models.shared import db
import re

app = Flask(__name__)
app.url_map.strict_slashes = False
bcrypt = Bcrypt(app)

app.config['SQLALCHEMY_DATABASE_URI']=os.environ.get('DATABASE_URL', 'postgres://localhost/game_exchange')
# app.config['SQLALCHEMY_DATABASE_URI']='postgres://localhost/game_exchange'

app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.url_map.strict_slashes = False

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

login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = "login"
app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY')
CsrfProtect(app)

# TODO - Refactor database design
class User(db.Model, UserMixin):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True, unique=True)
    username = db.Column(db.Text(), nullable=False, unique=True)
    password = db.Column(db.Text(), nullable=False)
    email = db.Column(db.Text(), nullable=False, unique=True)
    date_joined = db.Column(db.DateTime(), default=datetime.datetime.utcnow)