-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathfront_end.py
More file actions
25 lines (19 loc) · 733 Bytes
/
Copy pathfront_end.py
File metadata and controls
25 lines (19 loc) · 733 Bytes
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from flask import Flask, render_template
import requests
from requests.auth import HTTPBasicAuth
app = Flask(__name__)
@app.route("/")
def display_movies():
r = requests.get('http://localhost:5000/api/movies', auth=('twaits', 'Passphrase1'))
movies = r.json()['movies']
return render_template('home.html', movies=movies)
@app.route("/movies/<int:movie_id>")
def display_movie(movie_id):
url = "http://localhost:5000/api/movies/" + str(movie_id)
r = requests.get(url, auth=('twaits', 'Passphrase1'))
movie = r.json()['movie']
return render_template('movie.html', movie=movie)
if __name__ == "__main__":
app.run(host='0.0.0.0', port=5001, debug=True)