abort, render_template, flash from contextlib import closing @app.route('/') def index(): return 'Hello World' # configuration DATABASE = '/tmp/flaskr.db' DEBUG = True SECRET_KEY = 'development key' USERNAME = '******' PASSWORD = '******' # create our little application :) app = Flask(__name__) app.config.from_object(__name__) #app.config.from_envvar(__name__) def connect_db(): return sqlite3.connect(app.config['DATABASE']) def init_db(): with closing(connect_db()) as db: with app.open_resource('schema.sql') as f: db.cursor().executescript(f.read()) db.commit() if __name__ == '__main__': app.run(debug=True)
# save it to static folder file.save("myProject/static/file/client.csv") Session = sessionmaker(bind=engine) session = Session() conn = engine.connect() try: conn.execute("DROP TABLE inbox_table") except sqlalchemy.exc.OperationalError: print("The table has been deleted") try: conn.execute("DROP TABLE dropdown_table_new") except sqlalchemy.exc.OperationalError: print("The table has been deleted") # Commit the changes session.commit() # Close the session session.close() # generate new tables g = generate("client.csv", "famillesall_04-25-2019.csv", num) g.gen() return redirect(url_for('index')) @app.route("/setting", methods=['GET', 'POST']) def setting(): return render_template('setting.html') if __name__ == '__main__': app.run(debug=True)