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.2 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
45
  1. from flask import Flask,render_template,jsonify,request
  2. from src.pipline.prediction_pipline import PredictionPipline,CustomData
  3. import os
  4. app=Flask(__name__)
  5. @app.route('/')
  6. def home_page():
  7. return render_template("index.html")
  8. @app.route('/train')
  9. def train():
  10. os.system('dvc repro')
  11. jsonify('Train success')
  12. @app.route("/predict",methods=["GET","POST"])
  13. def predict_datapoint():
  14. if request.method=="GET":
  15. return render_template("form.html")
  16. else:
  17. data=CustomData(
  18. carat=float(request.form.get("carat")),
  19. depth=float(request.form.get("depth")),
  20. table=float(request.form.get("table")),
  21. x=float(request.form.get("x")),
  22. y=float(request.form.get("y")),
  23. z=float(request.form.get("z")),
  24. cut=request.form.get("cut"),
  25. color=request.form.get("color"),
  26. clarity=request.form.get("clarity")
  27. )
  28. final_data=data.get_data_as_df()
  29. predict_pipeline=PredictionPipline()
  30. pred=predict_pipeline.predict(final_data)
  31. result=round(pred[0],2)
  32. return render_template('result.html',final_result=result)
  33. if __name__=="__main__":
  34. app.run(host="0.0.0.0",port=8000)
Tip!

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

Comments

Loading...