diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 000000000..26d33521a --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/appInsightsSettings.xml b/.idea/appInsightsSettings.xml new file mode 100644 index 000000000..23b2e1fe4 --- /dev/null +++ b/.idea/appInsightsSettings.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/caches/deviceStreaming.xml b/.idea/caches/deviceStreaming.xml new file mode 100644 index 000000000..51d2b6186 --- /dev/null +++ b/.idea/caches/deviceStreaming.xml @@ -0,0 +1,1258 @@ + + + + + + \ No newline at end of file diff --git a/.idea/codespaces-flask.iml b/.idea/codespaces-flask.iml new file mode 100644 index 000000000..d6ebd4805 --- /dev/null +++ b/.idea/codespaces-flask.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 000000000..1945ce5fd --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 000000000..6530c310a --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..35eb1ddfb --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 31d8ab9c1..8b1378917 100644 --- a/README.md +++ b/README.md @@ -1,13 +1 @@ -# GitHub Codespaces ♥️ Flask -Welcome to your shiny new Codespace running Flask! We've got everything fired up and running for you to explore Flask. - -You've got a blank canvas to work on from a git perspective as well. There's a single initial commit with the what you're seeing right now - where you go from here is up to you! - -Everything you do here is contained within this one codespace. There is no repository on GitHub yet. If and when you’re ready you can click "Publish Branch" and we’ll create your repository and push up your project. If you were just exploring then and have no further need for this code then you can simply delete your codespace and it's gone forever. - -To run this application: - -``` -flask --debug run -``` diff --git a/app2.py b/app2.py new file mode 100644 index 000000000..289dd7c0c --- /dev/null +++ b/app2.py @@ -0,0 +1,12 @@ +from flask import Flask, jsonify +import random + +app = Flask(__name__) + +@app.route('/random', methods=['GET']) +def random_number(): + number = random.randint(1, 100) + return jsonify({'random_number': number}) + +if __name__ == '__main__': + app.run(debug=True) diff --git a/dict.py b/dict.py new file mode 100644 index 000000000..475348769 --- /dev/null +++ b/dict.py @@ -0,0 +1,43 @@ +# 创建一个空字典 +fruits = {} + +# 创建一个包含一些水果及其数量的字典 +fruits = { + 'apple': 10, + 'banana': 5, + 'orange': 8 +} +# 访问字典中的值 +print(fruits['apple']) # 输出: 10 +# 添加一个新的键值对 +fruits['mango'] = 15 + +# 更新一个已有的键值对 +fruits['banana'] = 7 + +print(fruits) +# 输出: {'apple': 10, 'banana': 7, 'orange': 8, 'mango': 15} +# 删除一个键值对 +del fruits['orange'] + +print(fruits) +# 输出: {'apple': 10, 'banana': 7, 'mango': 15} + +# 遍历字典中的键值对 +for fruit, quantity in fruits.items(): + print(f"The quantity of {fruit} is {quantity}") + +# 检查键是否在字典中 +if 'apple' in fruits: + print("Apple is in the dictionary") + +if 'grape' not in fruits: + print("Grape is not in the dictionary") + +# 获取所有的键 +keys = fruits.keys() +print(keys) # 输出: dict_keys(['apple', 'banana', 'mango']) + +# 获取所有的值 +values = fruits.values() +print(values) # 输出: dict_values([10, 7, 15]) \ No newline at end of file diff --git a/students.json b/students.json new file mode 100644 index 000000000..67995e031 --- /dev/null +++ b/students.json @@ -0,0 +1,18 @@ +[ + { + "name": "Alice", + "age": 23, + "courses": [ + "Math", + "Science" + ] + }, + { + "name": "Charlie", + "age": 24, + "courses": [ + "Art", + "Design" + ] + } +] \ No newline at end of file diff --git a/students.py b/students.py new file mode 100644 index 000000000..87775b9f7 --- /dev/null +++ b/students.py @@ -0,0 +1,39 @@ +import json + +# 读取 JSON 文件 +with open('students.json', 'r') as file: + students = json.load(file) + +print(students) + +# 遍历学生列表 +for student in students: + name = student['name'] + courses = student['courses'] + print(f"Student: {name}") + print("Courses:") + for course in courses: + print(f" - {course}") + +# 添加新学生 +new_student = { + "name": "Charlie", + "age": 24, + "courses": ["Art", "Design"] +} +students.append(new_student) + +# 将更新后的数据写回到 JSON 文件 +with open('students.json', 'w') as file: + json.dump(students, file, indent=4) + +print("New student added.") + +# 删除名为 "Bob" 的学生 +students = [student for student in students if student['name'] != 'Bob'] + +# 将更新后的数据写回到 JSON 文件 +with open('students.json', 'w') as file: + json.dump(students, file, indent=4) + +print("Student 'Bob' deleted.") \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 7bee67b55..91458ae75 100644 --- a/templates/index.html +++ b/templates/index.html @@ -7,7 +7,7 @@

- GitHub Codespaces ♥️ Flask + GitHub Codespaces ♥️hello wulb Flask

Edit templates/index.html and refresh to see your changes! diff --git a/templates/settings.html b/templates/settings.html new file mode 100644 index 000000000..d0d3e02cf --- /dev/null +++ b/templates/settings.html @@ -0,0 +1,30 @@ + + + + API Settings + + + +

+
+

API Settings

+
+
+ + +
+
+ + +
+
+ + +
+ +
+

Back to Home

+
+
+ +