Esempio n. 1
0
from flask import Flask, render_template
from flask_restful import Api
from resources.hotel import Hotels, Hotel

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
api = Api(app)


@app.before_first_request
def create_db():
    db.create_all()


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


api.add_resource(Hotels, '/hotels')
api.add_resource(Hotel, '/hotels/<string:hotel_id>')

if __name__ == '__main__':
    from sql_alchemy import db
    db.init_app(app)
    app.run(debug=True)
Esempio n. 2
0
def create_app():
    from sql_alchemy import db
    db.init_app(app)
    return app