-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
40 lines (31 loc) · 1.23 KB
/
Copy pathapp.py
File metadata and controls
40 lines (31 loc) · 1.23 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
from datetime import datetime
from flask import Flask, render_template, request, redirect, url_for, send_from_directory
import requests
import os
app = Flask(__name__)
@app.route('/')
def index():
print('Request for index page received')
return render_template('index.html')
@app.route('/favicon.ico')
def favicon():
return send_from_directory(os.path.join(app.root_path, 'static'),
'favicon.ico', mimetype='image/vnd.microsoft.icon')
@app.route('/hello', methods=['POST'])
def hello():
name = request.form.get('name')
if name:
print('Request for hello page received with name=%s' % name)
response = requests.get('https://adventureapim.azure-api.net/AdventureFunctionApp/GradingTriggerv3?name=1854'),
headers={
"Ocp-Apim-Subscription-Key": "ec610f8bddfe41ba80bcdca6ac051ef0"
}
print(response)
#instead of rendering hello.html I need to call and API
# return render_template('hello.html', name = name)
return render_template('hello.html', name = name)
else:
print('Request for hello page received with no name or blank name -- redirecting')
return redirect(url_for('index'))
if __name__ == '__main__':
app.run()