Spaces:
Sleeping
Sleeping
IZERE HIRWA Roger commited on
Commit ·
818ef98
1
Parent(s): f720b2c
- .env +2 -2
- app.py +2 -2
- chatbot/admin.js +2 -2
- chatbot/admin_advanced.js +2 -2
- chatbot/app.js +1 -1
- chatbot/auth.js +1 -1
- chatbot/config.js +3 -3
- chatbot/js/config.js +1 -1
- chatbot/landing.js +1 -1
- chatbot/login.js +1 -1
- chatbot/professional.js +2 -2
- chatbot/professional_advanced.js +2 -2
- chatbot/register.js +1 -1
- config.py +2 -2
- setup_without_ollama.py +3 -3
- tests/run_simple_aimhsa.py +2 -2
- working_api.py +1 -1
.env
CHANGED
|
@@ -4,10 +4,10 @@ DEBUG=True
|
|
| 4 |
|
| 5 |
# Server Configuration
|
| 6 |
SERVER_HOST=0.0.0.0
|
| 7 |
-
SERVER_PORT=
|
| 8 |
|
| 9 |
# For production hosting (Heroku, Railway, etc.)
|
| 10 |
-
PORT=
|
| 11 |
|
| 12 |
# API Configuration (leave empty for relative URLs)
|
| 13 |
API_BASE_URL=
|
|
|
|
| 4 |
|
| 5 |
# Server Configuration
|
| 6 |
SERVER_HOST=0.0.0.0
|
| 7 |
+
SERVER_PORT=7860
|
| 8 |
|
| 9 |
# For production hosting (Heroku, Railway, etc.)
|
| 10 |
+
PORT=7860
|
| 11 |
|
| 12 |
# API Configuration (leave empty for relative URLs)
|
| 13 |
API_BASE_URL=
|
app.py
CHANGED
|
@@ -3765,7 +3765,7 @@ def get_recent_assessments():
|
|
| 3765 |
finally:
|
| 3766 |
conn.close()
|
| 3767 |
|
| 3768 |
-
# Update run configuration to use port
|
| 3769 |
# --- PROFESSIONAL DASHBOARD API ENDPOINTS ---
|
| 3770 |
|
| 3771 |
@app.put("/professional/profile")
|
|
@@ -5030,4 +5030,4 @@ def get_sms_status():
|
|
| 5030 |
return jsonify({'error': f'Failed to get SMS status: {str(e)}'}), 500
|
| 5031 |
|
| 5032 |
if __name__ == "__main__":
|
| 5033 |
-
app.run(host="0.0.0.0", port=
|
|
|
|
| 3765 |
finally:
|
| 3766 |
conn.close()
|
| 3767 |
|
| 3768 |
+
# Update run configuration to use port 7860 for API only
|
| 3769 |
# --- PROFESSIONAL DASHBOARD API ENDPOINTS ---
|
| 3770 |
|
| 3771 |
@app.put("/professional/profile")
|
|
|
|
| 5030 |
return jsonify({'error': f'Failed to get SMS status: {str(e)}'}), 500
|
| 5031 |
|
| 5032 |
if __name__ == "__main__":
|
| 5033 |
+
app.run(host="0.0.0.0", port=7860, debug=True)
|
chatbot/admin.js
CHANGED
|
@@ -9,8 +9,8 @@
|
|
| 9 |
try {
|
| 10 |
const loc = window.location;
|
| 11 |
if (loc.port === '8000') {
|
| 12 |
-
return `${loc.protocol}//${loc.hostname}:
|
| 13 |
-
} else if (loc.port === '
|
| 14 |
return loc.origin;
|
| 15 |
} else {
|
| 16 |
return 'https://prodevroger-ishingiro.hf.space';
|
|
|
|
| 9 |
try {
|
| 10 |
const loc = window.location;
|
| 11 |
if (loc.port === '8000') {
|
| 12 |
+
return `${loc.protocol}//${loc.hostname}:7860`;
|
| 13 |
+
} else if (loc.port === '7860' || loc.port === '') {
|
| 14 |
return loc.origin;
|
| 15 |
} else {
|
| 16 |
return 'https://prodevroger-ishingiro.hf.space';
|
chatbot/admin_advanced.js
CHANGED
|
@@ -17,8 +17,8 @@
|
|
| 17 |
try {
|
| 18 |
const loc = window.location;
|
| 19 |
if (loc.port === '8000') {
|
| 20 |
-
apiRoot = `${loc.protocol}//${loc.hostname}:
|
| 21 |
-
} else if (loc.port === '
|
| 22 |
apiRoot = loc.origin;
|
| 23 |
} else {
|
| 24 |
apiRoot = 'https://prodevroger-ishingiro.hf.space';
|
|
|
|
| 17 |
try {
|
| 18 |
const loc = window.location;
|
| 19 |
if (loc.port === '8000') {
|
| 20 |
+
apiRoot = `${loc.protocol}//${loc.hostname}:7860`;
|
| 21 |
+
} else if (loc.port === '7860' || loc.port === '') {
|
| 22 |
apiRoot = loc.origin;
|
| 23 |
} else {
|
| 24 |
apiRoot = 'https://prodevroger-ishingiro.hf.space';
|
chatbot/app.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
| 5 |
return window.AIMHSA.Config.getApiBaseUrl();
|
| 6 |
}
|
| 7 |
// Fallback to auto-detection
|
| 8 |
-
return `http://${window.location.hostname}:${window.location.port || '
|
| 9 |
};
|
| 10 |
|
| 11 |
const API_BASE_URL = getAPIBaseUrl();
|
|
|
|
| 5 |
return window.AIMHSA.Config.getApiBaseUrl();
|
| 6 |
}
|
| 7 |
// Fallback to auto-detection
|
| 8 |
+
return `http://${window.location.hostname}:${window.location.port || '7860'}`;
|
| 9 |
};
|
| 10 |
|
| 11 |
const API_BASE_URL = getAPIBaseUrl();
|
chatbot/auth.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
| 8 |
}
|
| 9 |
|
| 10 |
// Fallback to auto-detection
|
| 11 |
-
return `http://${window.location.hostname}:${window.location.port || '
|
| 12 |
};
|
| 13 |
|
| 14 |
const API_BASE_URL = getAPIBaseUrl();
|
|
|
|
| 8 |
}
|
| 9 |
|
| 10 |
// Fallback to auto-detection
|
| 11 |
+
return `http://${window.location.hostname}:${window.location.port || '7860'}`;
|
| 12 |
};
|
| 13 |
|
| 14 |
const API_BASE_URL = getAPIBaseUrl();
|
chatbot/config.js
CHANGED
|
@@ -180,11 +180,11 @@
|
|
| 180 |
// Smart API URL detection
|
| 181 |
if (currentLocation.port === '8000') {
|
| 182 |
// Development server (likely Python/Django)
|
| 183 |
-
this.config.api.baseUrl = `${currentLocation.protocol}//${currentLocation.hostname}:
|
| 184 |
} else if (currentLocation.port === '3000') {
|
| 185 |
// React development server
|
| 186 |
-
this.config.api.baseUrl = `${currentLocation.protocol}//${currentLocation.hostname}:
|
| 187 |
-
} else if (currentLocation.port === '
|
| 188 |
// Running on API port
|
| 189 |
this.config.api.baseUrl = currentLocation.origin;
|
| 190 |
} else if (currentLocation.port === '80' || currentLocation.port === '443' || !currentLocation.port) {
|
|
|
|
| 180 |
// Smart API URL detection
|
| 181 |
if (currentLocation.port === '8000') {
|
| 182 |
// Development server (likely Python/Django)
|
| 183 |
+
this.config.api.baseUrl = `${currentLocation.protocol}//${currentLocation.hostname}:7860`;
|
| 184 |
} else if (currentLocation.port === '3000') {
|
| 185 |
// React development server
|
| 186 |
+
this.config.api.baseUrl = `${currentLocation.protocol}//${currentLocation.hostname}:7860`;
|
| 187 |
+
} else if (currentLocation.port === '7860') {
|
| 188 |
// Running on API port
|
| 189 |
this.config.api.baseUrl = currentLocation.origin;
|
| 190 |
} else if (currentLocation.port === '80' || currentLocation.port === '443' || !currentLocation.port) {
|
chatbot/js/config.js
CHANGED
|
@@ -85,7 +85,7 @@ class AppConfig {
|
|
| 85 |
case 'development':
|
| 86 |
// In development, API might be on different port
|
| 87 |
if (port === '8000' || port === '3000') {
|
| 88 |
-
return `${protocol}//${hostname}:
|
| 89 |
}
|
| 90 |
return ''; // Same origin
|
| 91 |
|
|
|
|
| 85 |
case 'development':
|
| 86 |
// In development, API might be on different port
|
| 87 |
if (port === '8000' || port === '3000') {
|
| 88 |
+
return `${protocol}//${hostname}:7860`;
|
| 89 |
}
|
| 90 |
return ''; // Same origin
|
| 91 |
|
chatbot/landing.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
'use strict';
|
| 4 |
|
| 5 |
// Get API URL from environment or use current host
|
| 6 |
-
const API_BASE_URL = `http://${window.location.hostname}:${window.location.port || '
|
| 7 |
|
| 8 |
// Smooth scrolling for navigation links
|
| 9 |
function initSmoothScrolling() {
|
|
|
|
| 3 |
'use strict';
|
| 4 |
|
| 5 |
// Get API URL from environment or use current host
|
| 6 |
+
const API_BASE_URL = `http://${window.location.hostname}:${window.location.port || '7860'}`;
|
| 7 |
|
| 8 |
// Smooth scrolling for navigation links
|
| 9 |
function initSmoothScrolling() {
|
chatbot/login.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
(() => {
|
| 2 |
-
const API_BASE_URL = `http://${window.location.hostname}:${window.location.port || '
|
| 3 |
|
| 4 |
// Elements
|
| 5 |
const loginForm = document.getElementById('loginForm');
|
|
|
|
| 1 |
(() => {
|
| 2 |
+
const API_BASE_URL = `http://${window.location.hostname}:${window.location.port || '7860'}`;
|
| 3 |
|
| 4 |
// Elements
|
| 5 |
const loginForm = document.getElementById('loginForm');
|
chatbot/professional.js
CHANGED
|
@@ -10,8 +10,8 @@
|
|
| 10 |
// Fallback to auto-detection
|
| 11 |
const loc = window.location;
|
| 12 |
if (loc.port === '8000') {
|
| 13 |
-
return `${loc.protocol}//${loc.hostname}:
|
| 14 |
-
} else if (loc.port === '
|
| 15 |
return loc.origin;
|
| 16 |
} else {
|
| 17 |
return 'https://prodevroger-ishingiro.hf.space';
|
|
|
|
| 10 |
// Fallback to auto-detection
|
| 11 |
const loc = window.location;
|
| 12 |
if (loc.port === '8000') {
|
| 13 |
+
return `${loc.protocol}//${loc.hostname}:7860`;
|
| 14 |
+
} else if (loc.port === '7860' || loc.port === '') {
|
| 15 |
return loc.origin;
|
| 16 |
} else {
|
| 17 |
return 'https://prodevroger-ishingiro.hf.space';
|
chatbot/professional_advanced.js
CHANGED
|
@@ -11,8 +11,8 @@
|
|
| 11 |
try {
|
| 12 |
const loc = window.location;
|
| 13 |
if (loc.port === '8000') {
|
| 14 |
-
apiRoot = `${loc.protocol}//${loc.hostname}:
|
| 15 |
-
} else if (loc.port === '
|
| 16 |
apiRoot = loc.origin;
|
| 17 |
} else {
|
| 18 |
apiRoot = 'https://prodevroger-ishingiro.hf.space';
|
|
|
|
| 11 |
try {
|
| 12 |
const loc = window.location;
|
| 13 |
if (loc.port === '8000') {
|
| 14 |
+
apiRoot = `${loc.protocol}//${loc.hostname}:7860`;
|
| 15 |
+
} else if (loc.port === '7860' || loc.port === '') {
|
| 16 |
apiRoot = loc.origin;
|
| 17 |
} else {
|
| 18 |
apiRoot = 'https://prodevroger-ishingiro.hf.space';
|
chatbot/register.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
(() => {
|
| 2 |
-
const API_BASE_URL = `http://${window.location.hostname}:${window.location.port || '
|
| 3 |
|
| 4 |
// Elements
|
| 5 |
const registerForm = document.getElementById('registerForm');
|
|
|
|
| 1 |
(() => {
|
| 2 |
+
const API_BASE_URL = `http://${window.location.hostname}:${window.location.port || '7860'}`;
|
| 3 |
|
| 4 |
// Elements
|
| 5 |
const registerForm = document.getElementById('registerForm');
|
config.py
CHANGED
|
@@ -14,7 +14,7 @@ class Config:
|
|
| 14 |
|
| 15 |
# Server Configuration
|
| 16 |
HOST = os.getenv('SERVER_HOST', '0.0.0.0')
|
| 17 |
-
PORT = int(os.getenv('SERVER_PORT', '
|
| 18 |
DEBUG = os.getenv('DEBUG', 'False').lower() == 'true'
|
| 19 |
|
| 20 |
# API Configuration
|
|
@@ -53,7 +53,7 @@ class DevelopmentConfig(Config):
|
|
| 53 |
"""Development environment configuration"""
|
| 54 |
DEBUG = True
|
| 55 |
HOST = '0.0.0.0'
|
| 56 |
-
PORT =
|
| 57 |
|
| 58 |
class ProductionConfig(Config):
|
| 59 |
"""Production environment configuration"""
|
|
|
|
| 14 |
|
| 15 |
# Server Configuration
|
| 16 |
HOST = os.getenv('SERVER_HOST', '0.0.0.0')
|
| 17 |
+
PORT = int(os.getenv('SERVER_PORT', '7860'))
|
| 18 |
DEBUG = os.getenv('DEBUG', 'False').lower() == 'true'
|
| 19 |
|
| 20 |
# API Configuration
|
|
|
|
| 53 |
"""Development environment configuration"""
|
| 54 |
DEBUG = True
|
| 55 |
HOST = '0.0.0.0'
|
| 56 |
+
PORT = 7860
|
| 57 |
|
| 58 |
class ProductionConfig(Config):
|
| 59 |
"""Production environment configuration"""
|
setup_without_ollama.py
CHANGED
|
@@ -167,7 +167,7 @@ def setup_openai_compatible():
|
|
| 167 |
config_lines.extend([
|
| 168 |
"# Server Configuration",
|
| 169 |
"SERVER_HOST=0.0.0.0",
|
| 170 |
-
"SERVER_PORT=
|
| 171 |
"FLASK_ENV=development",
|
| 172 |
"DEBUG=True",
|
| 173 |
"",
|
|
@@ -209,7 +209,7 @@ services:
|
|
| 209 |
aimhsa:
|
| 210 |
build: .
|
| 211 |
ports:
|
| 212 |
-
- "
|
| 213 |
environment:
|
| 214 |
- FLASK_ENV=production
|
| 215 |
- DEBUG=False
|
|
@@ -270,7 +270,7 @@ RUN mkdir -p storage data
|
|
| 270 |
RUN python init_database.py
|
| 271 |
|
| 272 |
# Expose port
|
| 273 |
-
EXPOSE
|
| 274 |
|
| 275 |
# Run application
|
| 276 |
CMD ["python", "app.py"]
|
|
|
|
| 167 |
config_lines.extend([
|
| 168 |
"# Server Configuration",
|
| 169 |
"SERVER_HOST=0.0.0.0",
|
| 170 |
+
"SERVER_PORT=7860",
|
| 171 |
"FLASK_ENV=development",
|
| 172 |
"DEBUG=True",
|
| 173 |
"",
|
|
|
|
| 209 |
aimhsa:
|
| 210 |
build: .
|
| 211 |
ports:
|
| 212 |
+
- "7860:7860"
|
| 213 |
environment:
|
| 214 |
- FLASK_ENV=production
|
| 215 |
- DEBUG=False
|
|
|
|
| 270 |
RUN python init_database.py
|
| 271 |
|
| 272 |
# Expose port
|
| 273 |
+
EXPOSE 7860
|
| 274 |
|
| 275 |
# Run application
|
| 276 |
CMD ["python", "app.py"]
|
tests/run_simple_aimhsa.py
CHANGED
|
@@ -63,7 +63,7 @@ class ChatBotHandler(SimpleHTTPRequestHandler):
|
|
| 63 |
except Exception as e:
|
| 64 |
self.send_error(500, f"Server error: {str(e)}")
|
| 65 |
|
| 66 |
-
def run_simple_backend(api_port=
|
| 67 |
"""Run the simplified Flask backend"""
|
| 68 |
print(f"🚀 Starting Simple AIMHSA Backend on port {api_port}...")
|
| 69 |
|
|
@@ -116,7 +116,7 @@ def run_frontend(frontend_port=8000):
|
|
| 116 |
|
| 117 |
def main():
|
| 118 |
parser = argparse.ArgumentParser(description="Simple AIMHSA Launcher")
|
| 119 |
-
parser.add_argument("--api-port", "-a", type=int, default=
|
| 120 |
parser.add_argument("--frontend-port", "-f", type=int, default=8000, help="Frontend port (default: 8000)")
|
| 121 |
parser.add_argument("--backend-only", "-b", action="store_true", help="Run only backend")
|
| 122 |
parser.add_argument("--frontend-only", "-w", action="store_true", help="Run only frontend")
|
|
|
|
| 63 |
except Exception as e:
|
| 64 |
self.send_error(500, f"Server error: {str(e)}")
|
| 65 |
|
| 66 |
+
def run_simple_backend(api_port=7860):
|
| 67 |
"""Run the simplified Flask backend"""
|
| 68 |
print(f"🚀 Starting Simple AIMHSA Backend on port {api_port}...")
|
| 69 |
|
|
|
|
| 116 |
|
| 117 |
def main():
|
| 118 |
parser = argparse.ArgumentParser(description="Simple AIMHSA Launcher")
|
| 119 |
+
parser.add_argument("--api-port", "-a", type=int, default=7860, help="Backend port (default: 7860)")
|
| 120 |
parser.add_argument("--frontend-port", "-f", type=int, default=8000, help="Frontend port (default: 8000)")
|
| 121 |
parser.add_argument("--backend-only", "-b", action="store_true", help="Run only backend")
|
| 122 |
parser.add_argument("--frontend-only", "-w", action="store_true", help="Run only frontend")
|
working_api.py
CHANGED
|
@@ -113,5 +113,5 @@ if __name__ == '__main__':
|
|
| 113 |
print("RAG System: Ready")
|
| 114 |
print("Embeddings: Loaded")
|
| 115 |
print("Models: Available via OpenAI Client")
|
| 116 |
-
app.run(host='0.0.0.0', port=
|
| 117 |
|
|
|
|
| 113 |
print("RAG System: Ready")
|
| 114 |
print("Embeddings: Loaded")
|
| 115 |
print("Models: Available via OpenAI Client")
|
| 116 |
+
app.run(host='0.0.0.0', port=7860, debug=True)
|
| 117 |
|