-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython
More file actions
40 lines (34 loc) · 1.02 KB
/
python
File metadata and controls
40 lines (34 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def analyze_web_data(pages):
"""
Example analysis: count word frequency of 'Python' in each page.
"""
data = []
for url, html in pages.items():
count = html.lower().count('python')
data.append({'url': url, 'python_count': count})
df = pd.DataFrame(data)
print("\nData Analysis: Count of 'Python' occurrences per URL")
print(df)
return df
# ----------------------------
# Project 3: Simple REST API Server with Flask
# ----------------------------
app = Flask(__name__)
# In-memory storage for demo
items = []
@app.route('/items', methods=['GET'])
def get_items():
return jsonify(items)
@app.route('/items', methods=['POST'])
def add_item():
data = request.get_json()
item = {
'id': len(items) + 1,
'name': data.get('name', 'Unnamed'),
'description': data.get('description', '')
}
items.append(item)
return jsonify(item), 201
def run_api_server():
print("Starting Flask API server on http://127.0.0.1:5000")
app.run(debug=True)