flask_crud_app/app.py

38 lines
1.1 KiB
Python
Raw Normal View History

2025-01-29 05:27:19 +00:00
from flask import Flask, request, render_template, redirect, abort, send_file
from sqlalchemy import exc
from models import *
import csv
2025-01-30 07:37:21 +00:00
from process_csv import process_csv # Import the CSV processing function
# Import the Blueprints
from routes.viewall import viewall_bp
from routes.viewasset import viewasset_bp
from routes.create import addasset_bp
from routes.update import update_bp
from routes.delete import delete_bp
from routes.upload import upload_bp
2025-01-29 05:27:19 +00:00
app = Flask(__name__)
2025-01-30 07:37:21 +00:00
app.secret_key = 'your_secret_key' # Required for flashing messages and session
2025-01-29 10:05:36 +00:00
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://assetadmin:1234@localhost/asset_test_db'
2025-01-29 05:27:19 +00:00
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db.init_app(app)
2025-01-30 07:37:21 +00:00
# Register the Blueprints
app.register_blueprint(viewall_bp)
app.register_blueprint(viewasset_bp)
app.register_blueprint(addasset_bp)
app.register_blueprint(update_bp)
app.register_blueprint(delete_bp)
app.register_blueprint(upload_bp)
2025-01-29 05:27:19 +00:00
2025-01-29 10:05:36 +00:00
with app.app_context():
2025-01-29 05:27:19 +00:00
db.create_all()
@app.route('/')
def index():
2025-01-29 10:38:32 +00:00
return redirect('/viewall')
2025-01-29 05:27:19 +00:00
if __name__ == '__main__':
app.run(host='localhost', port=5000)