-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
82 lines (65 loc) · 1.92 KB
/
main.py
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from flask import Flask, render_template, request
from predicter import predict, load_model
app = Flask(__name__)
property_model = load_model('pickle_model_v3.pkl')
@app.route('/', methods=["GET"])
def index():
return render_template('index.html', title='Home')
@app.route('/', methods=['POST'])
def calculate():
location = int(request.form['location'])
area = float(request.form['area'])
year = int(request.form['year'])
rooms = int(request.form['rooms'])
level = int(request.form['level'])
state = int(request.form['state'])
city = int(request.form['city'])
prediction = predict(location, area, year, rooms, level, state, property_model)
if level == 0:
level = "Parter"
else:
level = f"Poziom {level}"
cities = [
'Kraków', 'Warszawa', 'Łódź'
]
locations = [
'Bieńczyce',
'Bieżanów - Prokocim',
'Bronowice',
'Dębniki',
'Grzegórzki',
'Krowodrza',
'Łagiewniki - Borek Fałęcki',
'Mistrzejowice',
'Nowa Huta',
'Podgórze',
'Podgórze Duchackie',
'Prądnik Biały',
'Prądnik Czerwony',
'Śródmieście',
'Stare Miasto',
'Swoszowice',
'Wzgórza Krzesławickie',
'Zwierzyniec'
]
states = [
'Do remontu',
'Do wykończenia',
'Do zamieszkania'
]
context = {
'prediction': prediction,
'location': locations[location],
'area': area,
'year': year,
'rooms': rooms,
'level': level,
'state': states[state],
'city': cities[city]
}
return render_template('calculate.html', title='Home', context=context)
@app.route('/about', methods=['GET'])
def about():
return render_template('about.html', )
if __name__ == "__main__":
app.run()