Skip to content

Commit

Permalink
Fix Netlify deployment structure
Browse files Browse the repository at this point in the history
  • Loading branch information
fadlyhts committed Nov 25, 2024
1 parent 436d041 commit 3c84e84
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
11 changes: 7 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from flask import Flask, request, render_template, jsonify
from flask_cors import CORS
import os
import pickle
import pandas as pd
import numpy as np

app = Flask(__name__)
app = Flask(__name__, static_folder='.', static_url_path='')
CORS(app)

# Load model
with open('stunting_model.pkl', 'rb') as f:
Expand Down Expand Up @@ -60,7 +63,7 @@ def predict_status(input_data):
all_possible_features = set(selected_features)
if hasattr(best_models[target], 'feature_names_in_'):
all_possible_features.update(best_models[target].feature_names_in_)

# Prepare features in correct order
X_pred = input_scaled[list(all_possible_features)].copy()

Expand All @@ -83,7 +86,7 @@ def predict_status(input_data):

@app.route('/')
def home():
return render_template('index.html')
return app.send_static_file('index.html')

@app.route('/predict', methods=['POST'])
def predict():
Expand Down Expand Up @@ -122,4 +125,4 @@ def predict():
return jsonify({'error': 'Terjadi kesalahan internal'}), 500

if __name__ == '__main__':
app.run(debug=True)
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 5000)))
4 changes: 1 addition & 3 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

[build]
command = "# no build command"
functions = "netlify/functions"
publish = "."
command = "# no build command needed"

[[redirects]]
from = "/*"
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
flask==2.0.1
flask-cors==3.0.10
pandas==1.3.3
numpy==1.21.2
scikit-learn==0.24.2
Expand Down

0 comments on commit 3c84e84

Please sign in to comment.