修改了演示代码
This commit is contained in:
		
							
								
								
									
										21
									
								
								app.py
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								app.py
									
									
									
									
									
								
							@@ -1,11 +1,14 @@
 | 
			
		||||
#-----------------------------------------------------------------------------------------
 | 
			
		||||
# Copyright (c) Microsoft Corporation. All rights reserved.
 | 
			
		||||
# Licensed under the MIT License. See LICENSE in the project root for license information.
 | 
			
		||||
#-----------------------------------------------------------------------------------------
 | 
			
		||||
# 简单的加法计算器
 | 
			
		||||
 | 
			
		||||
from flask import Flask
 | 
			
		||||
app = Flask(__name__)
 | 
			
		||||
def add_numbers(a, b):
 | 
			
		||||
    """计算两个数字的和"""
 | 
			
		||||
    return a + b
 | 
			
		||||
 | 
			
		||||
@app.route("/")
 | 
			
		||||
def hello():
 | 
			
		||||
    return app.send_static_file("index.html")
 | 
			
		||||
# 获取用户输入
 | 
			
		||||
print("简单的加法计算器")
 | 
			
		||||
num1 = float(input("请输入第一个数字: "))
 | 
			
		||||
num2 = float(input("请输入第二个数字: "))
 | 
			
		||||
 | 
			
		||||
# 计算并输出结果
 | 
			
		||||
result = add_numbers(num1, num2)
 | 
			
		||||
print(f"{num1} + {num2} = {result}")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user