-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathimdb_api.py
82 lines (70 loc) · 2.22 KB
/
imdb_api.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 3 12:03:37 2019
@author: Deepak
"""
from flask import Flask, render_template,redirect,url_for,request
from pymongo import MongoClient
app = Flask(__name__)
@app.route("/", methods=["GET"])
def index():
client = MongoClient()
db = client['IMDB']
collection = db['movies_data']
d=[]
curr = collection.find()
for i in curr:
d.append(i["movie_name"])
mydata={}
mydata["list"]=d
return render_template("index.html",data=mydata)
@app.route("/movie1/<ids>", methods=["GET"])
def movie1(ids):
client = MongoClient()
db = client['IMDB']
collection = db['movies_data']
curr = collection.find({'id':ids})
data={}
for i in curr:
data['id'] = i['id']
data["movie"]=i['movie_name']
data["rating"]=str(i['rating'])
data["cast"]=i['cast']
data["genre"]=i['genre']
data["runtime"]=str(i['runtime'])
return render_template("show_data.html",**data)
@app.route("/movie_name",methods=['POST'])
def movie_name():
if(request.method=="POST"):
name = request.form['movie_title']
client = MongoClient()
db = client['IMDB']
collection = db['movies_data']
curr = collection.find({'movie_name':name})
data={}
for i in curr:
data['id'] = i['id']
data["movie"]=i['movie_name']
data["rating"]=str(i['rating'])
data["cast"]=i['cast']
data["genre"]=i['genre']
data["runtime"]=str(i['runtime'])
return render_template("show_data.html",**data)
@app.route("/movie",methods=["POST"])
def my_from():
text = request.form['movieID']
return redirect(url_for('movie1',ids=text))
@app.route("/api2", methods=["GET"])
def api2():
client = MongoClient()
db = client['IMDB']
collection = db['movies_data']
d=[]
curr = collection.find()
for i in curr:
d.append(i["id"])
mydata={}
mydata["list"]=d
return render_template("API_2.html",data=mydata)
if __name__ == "__main__":
app.run()