batman (working version kinda)
This commit is contained in:
commit
6dd38036e7
65 changed files with 3950 additions and 0 deletions
71
run.py
Normal file
71
run.py
Normal file
|
@ -0,0 +1,71 @@
|
|||
import os
|
||||
import sys
|
||||
import importlib.util
|
||||
from flask import Flask, render_template
|
||||
from app import create_app
|
||||
|
||||
# Add the current directory to Python path
|
||||
current_dir = os.path.abspath(os.path.dirname(__file__))
|
||||
sys.path.insert(0, current_dir)
|
||||
|
||||
def create_basic_app():
|
||||
"""Create a Flask app without database dependencies"""
|
||||
app = Flask(__name__,
|
||||
template_folder=os.path.join(current_dir, 'app', 'templates'),
|
||||
static_folder=os.path.join(current_dir, 'app', 'static'))
|
||||
|
||||
# Basic configuration
|
||||
app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY', 'dev-key-placeholder')
|
||||
app.config['DEBUG'] = True
|
||||
|
||||
# Register basic routes
|
||||
register_routes(app)
|
||||
|
||||
# Add a fallback index route if no routes match
|
||||
@app.route('/')
|
||||
def index():
|
||||
return "Your Network Management Flask Application is running! Navigate to /dashboard to see content."
|
||||
|
||||
return app
|
||||
|
||||
def register_routes(app):
|
||||
"""Register blueprints without database dependencies"""
|
||||
routes_dir = os.path.join(current_dir, 'app', 'routes')
|
||||
|
||||
# Check if routes directory exists
|
||||
if not os.path.isdir(routes_dir):
|
||||
print(f"Warning: Routes directory {routes_dir} not found")
|
||||
return
|
||||
|
||||
# Try to register API blueprint which is simplest
|
||||
try:
|
||||
from app.routes.api import bp as api_bp
|
||||
app.register_blueprint(api_bp)
|
||||
print("Registered API blueprint")
|
||||
except Exception as e:
|
||||
print(f"Could not register API blueprint: {e}")
|
||||
|
||||
# Try to register other blueprints with basic error handling
|
||||
try:
|
||||
from app.routes.dashboard import bp as dashboard_bp
|
||||
app.register_blueprint(dashboard_bp)
|
||||
print("Registered dashboard blueprint")
|
||||
except ImportError as e:
|
||||
print(f"Could not import dashboard blueprint: {e}")
|
||||
|
||||
try:
|
||||
from app.routes.ipam import bp as ipam_bp
|
||||
app.register_blueprint(ipam_bp)
|
||||
print("Registered IPAM blueprint")
|
||||
except ImportError as e:
|
||||
print(f"Could not import IPAM blueprint: {e}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
print("Starting Flask app with SQLite database...")
|
||||
app = create_app('development')
|
||||
app.run(debug=True, host='0.0.0.0', port=5000)
|
||||
except Exception as e:
|
||||
print(f"Error starting Flask app: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
Loading…
Add table
Add a link
Reference in a new issue