import os
from flask import Flask
from routes.doc import doc_bp
from routes.file_management import file_management_bp
from routes.help import help_bp
def load_config(file):
with open(file, 'r', encoding='utf-8') as file:
for line in file:
line = line.strip()
if line.startswith('ip_address:'):
ip_address = line.split(':')[1].strip()
elif line.startswith('port:'):
port = line.split(':')[1].strip()
return ip_address, port
ip_address= "localhost"
port = 5000
print("ip: ", ip_address, "; port: ", port)
app = Flask(__name__, template_folder='./resources/templates')
app.register_blueprint(doc_bp)
app.register_blueprint(file_management_bp)
app.register_blueprint(help_bp)
if __name__ == '__main__':
try:
app.run(debug=True, host=ip_address, port=int(port))
except Exception as e:
print(f"Failed to start server on {ip_address}:{port}. Error: {e}")
print("Attempting to start server on 127.0.0.1...")
app.run(debug=True, host='127.0.0.1', port=5000)