Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite5aef81

Browse files
committed
add python app
1 parent1d65579 commite5aef81

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

‎app.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
fromflaskimportFlask,render_template
2+
fromdatetimeimportdatetime
3+
importrandom
4+
5+
app=Flask(__name__)
6+
7+
# Simple counter to track API requests
8+
request_counter=0
9+
10+
@app.route('/')
11+
defhome():
12+
returnrender_template('index.html')
13+
14+
@app.route('/api/data')
15+
defapi_data():
16+
globalrequest_counter
17+
request_counter+=1
18+
19+
# Sample data that simulates real-world API responses
20+
server_statuses= ["Healthy","Busy","Maintenance","Optimal"]
21+
sample_cities= ["New York","London","Tokyo","Sydney","Paris","Toronto"]
22+
23+
return {
24+
'message':f'Hello from Flask! Request #{request_counter}',
25+
'framework':'Flask',
26+
'language':'Python',
27+
'timestamp':datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
28+
'server_status':random.choice(server_statuses),
29+
'temperature':random.randint(15,35),# Celsius
30+
'city':random.choice(sample_cities),
31+
'users_online':random.randint(50,500),
32+
'total_requests':request_counter
33+
}
34+
35+
if__name__=='__main__':
36+
app.run(debug=True,host='localhost',port=5000)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp