devicetypeAPIGET1

This commit is contained in:
QuangMinh_123
2026-05-21 12:01:10 +07:00
parent 86383e7c03
commit 7aebcf9567
35 changed files with 2784 additions and 145 deletions

View File

@@ -1,26 +1,30 @@
from flask import Flask, jsonify
# from flask_cors import CORS
import os
from dotenv import load_dotenv
from flask import Flask
load_dotenv() # Đọc file .env
from common.exceptions.handler import (
register_error_handlers
)
app = Flask(__name__) # ← Đây là dòng quan trọng nhất
# Cho phép React (localhost:5173) gọi API từ backend
CORS(app, origins=["http://localhost:5173", "http://127.0.0.1:5173"])
from modules.device_type.routes import (
device_type_bp
)
@app.route('/')
def home():
return jsonify({
"message": "✅ Backend NDMS đang chạy thành công!",
"status": "ok"
})
app = Flask(__name__)
@app.route('/health')
def health():
return jsonify({"status": "healthy"})
# Register Global Exception Handlers
register_error_handlers(app)
# Phần này bạn hay dùng
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8000, debug=True)
# Register Blueprints
app.register_blueprint(
device_type_bp,
url_prefix="/api"
)
# @app.route("/")
# def home():
# return {
# "message": "NDMS Backend Running"
# }
if __name__ == "__main__":
app.run(debug=True)