58 lines
2.0 KiB
Python
58 lines
2.0 KiB
Python
import locale
|
|
|
|
from flask import Flask, render_template, request, redirect
|
|
|
|
from forms.SearchForm import SearchForm
|
|
from arztapi.APIHandler import APIHandler
|
|
|
|
app = Flask(__name__)
|
|
app.secret_key = "nosecretkey"
|
|
locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
|
|
|
|
|
|
@app.route('/')
|
|
def main_page():
|
|
search_form = SearchForm()
|
|
return render_template("index.html", form=search_form)
|
|
|
|
|
|
@app.route("/search", methods=["POST"])
|
|
def search_for_doctors_with_params():
|
|
search_form = SearchForm(request.form)
|
|
if search_form.validate():
|
|
location = search_form.location.data
|
|
distance = search_form.therapy_distance.data
|
|
therapy_types = search_form.therapy_type.data
|
|
therapy_age_range = search_form.therapy_age_range.data
|
|
therapy_setting = search_form.therapy_setting.data
|
|
amount_of_weeks = search_form.amount_of_weeks.data
|
|
|
|
print(f"Location: {location}")
|
|
print(f"Distance: {distance}")
|
|
print(f"Therapy Types: {therapy_types}")
|
|
print(f"Age Range: {therapy_age_range}")
|
|
print(f"Therapy Setting: {therapy_setting}")
|
|
print(f"Therapy Phone Types: {amount_of_weeks}")
|
|
|
|
else:
|
|
print(search_form.errors)
|
|
return redirect("/")
|
|
|
|
api_handler = APIHandler()
|
|
locations = api_handler.get_lat_lon_location_list(location)
|
|
if not locations:
|
|
return render_template("no_result.html")
|
|
location_match = locations[0]
|
|
base64_value = api_handler.calculate_req_value_base64(float(location_match["lat"]), float(location_match["lon"]))
|
|
api_handler.get_list_of_doctors(float(location_match['lat']), float(location_match['lon']), base64_value,
|
|
therapy_types, therapy_age_range, therapy_setting)
|
|
api_handler.get_general_doctor_information()
|
|
api_handler.filter_doctor_information_for_distance(distance*1000)
|
|
sorted_doctor_phone_times = api_handler.get_doctor_phone_times_sorted(amount_of_weeks)
|
|
|
|
return render_template("result.html", doctors=sorted_doctor_phone_times)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
app.run()
|