Skip to content

Commit e5aef81

Browse files
committed
add python app
1 parent 1d65579 commit e5aef81

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+
from flask import Flask, render_template
2+
from datetime import datetime
3+
import random
4+
5+
app = Flask(__name__)
6+
7+
# Simple counter to track API requests
8+
request_counter = 0
9+
10+
@app.route('/')
11+
def home():
12+
return render_template('index.html')
13+
14+
@app.route('/api/data')
15+
def api_data():
16+
global request_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)