-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
29 lines (23 loc) · 871 Bytes
/
app.py
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
from datetime import datetime
from flask import Flask, request, render_template
from flask_cors import CORS
import sys
app = Flask(__name__)
cors = CORS(app)
@app.route('/', methods=['GET', 'POST'])
def handle_request():
# Time when the server got the request
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
# Get the content of the request
request_info = '\n--------------------'
request_info += '\nI just got a request!'
request_info += '\n%s' % current_time
request_info += '\nRequest:\n%s' % request
request_info += '\nArgs:\n%s' % request.args
request_info += '\nBody:\n%s' % request.data
request_info += '\n--------------------\n'
# Print to terminal
print(request_info, file=sys.stderr)
# Show in the browser
return render_template("index.html", request_info=request_info.split('\n'))