Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

app.py 1.3 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
  1. from flask import Flask, render_template, request
  2. import os
  3. import numpy as np
  4. import pandas as pd
  5. from CarPrediction.pipeline.prediction import PredictionPipeline
  6. app = Flask(__name__)
  7. @app.route('/',methods=['GET'])
  8. def homepage():
  9. return render_template('index.html')
  10. @app.route('/train',methods=['GET'])
  11. def training():
  12. os.system("python main.py")
  13. return "Training Completed"
  14. @app.route('/predict',methods=['POST','GET'])
  15. def index():
  16. if request.method == 'POST':
  17. try:
  18. fixed_acidity = request.form['fixed_acidity']
  19. volatile_acidity = request.form['volatile_acidity']
  20. citric_acid = request.form['citric_acid']
  21. residual_sugar =request.form['residual_sugar']
  22. chlorides =request.form['chlorides']
  23. data = [fixed_acidity,volatile_acidity,citric_acid,residual_sugar,chlorides]
  24. data = np.array(data).reshape(1,5)
  25. obj = PredictionPipeline()
  26. predict = obj.predict(data)
  27. return render_template('results.html', prediction = str(predict))
  28. except Exception as e:
  29. print('The Exception message is: ',e)
  30. return 'something is wrong'
  31. else:
  32. return render_template('index.html')
  33. if __name__ == '__main__':
  34. app.run(host="0.0.0.0",port=8080)
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...