File tree 2 files changed +76
-1
lines changed
2 files changed +76
-1
lines changed Original file line number Diff line number Diff line change 6
6
from wtforms .validators import DataRequired
7
7
import requests
8
8
9
+ # CONSTANTS
10
+
11
+ MOVIE_DB_API_KEY = "YOUR API KEY"
12
+ MOVIE_DB_SEARCH_URL = "https://api.themoviedb.org/3/search/movie"
13
+ MOVIE_DB_INFO_URL = "https://api.themoviedb.org/3/movie"
14
+ MOVIE_DB_IMAGE_URL = "https://image.tmdb.org/t/p/w500"
15
+
9
16
app = Flask (__name__ )
10
17
11
18
# secret key
12
19
app .secret_key = b'\xb9 \xd6 \xc7 \xc4 \xb5 \xf0 \xc4 y\xc6 \xb0 \r \xc3 `!\xca ~'
13
-
20
+ # flask bootstrap
14
21
Bootstrap (app )
15
22
16
23
# creating db
@@ -84,6 +91,13 @@ def delete_movie():
84
91
@app .route ('/add' , methods = ["GET" , "POST" ])
85
92
def add_movie ():
86
93
form = FindMovieForm ()
94
+
95
+ # get information from The Movie database
96
+ if form .validate_on_submit ():
97
+ movie_title = form .title .data
98
+ response = requests .get (MOVIE_DB_SEARCH_URL , params = {"api_key" : MOVIE_DB_API_KEY , "query" : movie_title })
99
+ data = response .json ()["results" ]
100
+ return render_template ("select.html" , options = data )
87
101
return render_template ("add.html" , form = form )
88
102
89
103
Original file line number Diff line number Diff line change
1
+ {% extends 'bootstrap/base.html' %}
2
+ {% import 'bootstrap/wtf.html' as wtf %}
3
+
4
+ {% block styles %}
5
+ {{ super() }}
6
+
7
+ <!-- Google Fonts -->
8
+
9
+ < link
10
+ rel ="stylesheet "
11
+ href ="https://fonts.googleapis.com/css?family=Nunito+Sans:300,400,700 "
12
+ />
13
+ < link
14
+ rel ="stylesheet "
15
+ href ="https://fonts.googleapis.com/css?family=Poppins:300,400,700 "
16
+ />
17
+ < link
18
+ rel ="stylesheet "
19
+ href ="https://fonts.googleapis.com/css?family=Poppins:300,400,700 "
20
+ />
21
+
22
+ <!-- Font Awesome CSS -->
23
+ < link
24
+ rel ="stylesheet "
25
+ href ="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css "
26
+ integrity ="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA== "
27
+ crossorigin ="anonymous "
28
+ />
29
+
30
+ <!-- Custom CSS Styling -->
31
+ < link
32
+ rel ="stylesheet "
33
+ href ="{{ url_for('static', filename='css/styles.css') }} "
34
+ />
35
+ {% endblock %}
36
+
37
+ {% block title %} Select Movies {% endblock %}
38
+
39
+ {% block content %}
40
+ < div class ="container ">
41
+
42
+ < div class ="content ">
43
+ < h1 class ="heading "> Select Movie</ h1 >
44
+
45
+
46
+ < div class ="card " style ="width: 18rem; ">
47
+ < div class ="card-header ">
48
+ Select A Movie
49
+ </ div >
50
+ {% for movie in options: %}
51
+ < ul class ="list-group list-group-flush ">
52
+ < li class ="list-group-item "> {{ movie.title }} | ({{ movie.release_date }})</ li >
53
+ </ ul >
54
+ {% endfor %}
55
+ </ div >
56
+
57
+
58
+ </ div >
59
+
60
+ </ div >
61
+ {% endblock %}
You can’t perform that action at this time.
0 commit comments