DAS_2023_1/antonov_dmitry_lab_2/app2/app.py
2023-11-11 21:51:36 +04:00

29 lines
791 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from flask import Flask
app = Flask(__name__)
@app.route('/')
def process_data():
# ищет наименьшее число из файла /var/data/data.txt
data_file = '/var/data/data.txt'
# и сохраняет его третью степень в /var/result/result.txt
result_file = '/var/result/result.txt'
with open(data_file, 'r') as file:
numbers = [int(line.strip()) for line in file]
smallest_number = min(numbers)
# выводит наименьшее число
print(smallest_number)
result = smallest_number ** 3
with open(result_file, 'w') as file:
file.write(str(result))
return 'Результат успешно сохранен!\n'
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)