Может кто-нибудь объяснить, почему это приложение flask продолжает завершать работу на моем локальном хосте из-за неперехваченной ошибки?
Я пытаюсь создать приложение, которое будет принимать вставленный CSV-файл (все файлы имеют одинаковые столбцы и форма в упомянутом шаблоне), а затем выводить визуализации, такие как «nat». Однако, похоже, что-то идет не так, как надо !! Помогите !!
import os
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
app = Flask(__name__)
@app.route('/')
@app.route('/tadadata.html')
def form():
return render_template('tadadata.html')
@app.route('/main_program', methods=["POST"])
def main_program_view():
# Input file
file = request.files['input_file']
if not file:
return "No file"
# Put input file in dataframe
tourism_df = pd.read_csv(file)
#get relevant data
relevantdata = tourism_df.drop(columns=['Booked', 'Property name', 'Promotion code', 'Guest first name', 'Guest last name', 'Guest email', 'Guest phone number', 'Guest organisation', 'Guest address', 'Guest address2', 'Guest state', 'Guest post code', 'Check in date', 'Check out date', 'Arrival time', 'Guest comments', 'Requested newsletter', 'Status', 'Rate plans', 'Subtotal amount', 'Extra adult amount', 'Extra child amount' ,'Extra infant amount', 'Extras total amount', 'Credit card surcharge processed amount', 'Surcharge Percentage', 'Promotional Discount', 'Payment total', 'Payment Received', 'Number of adults', 'Number of children', 'Guest city', 'Number of infants', 'Number of Rooms', 'Custom Property Specific Data', 'Referral' ,'Payments deposit processed total', 'Payment outstanding', 'Mobile booking?', 'Promotion Description', 'Enter rates including fees', 'Fixed Taxes Total', 'Percentage Taxes Total', 'Rooms'])
nationalities = relevantdata['Guest country'].value_counts(normalize=True) * 100
nat = nationalities.plot.bar()
plt.ylabel('Percentage')
plt.title('Nationality')
return nat()
if __name__ == '__main__':
app.run(debug=True)