anonghost commited on
Commit
8b722c0
·
verified ·
1 Parent(s): 7deb3b9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, render_template, request
2
+ import instaloader
3
+
4
+ app = Flask(__name__)
5
+
6
+ @app.route('/', methods=['GET', 'POST'])
7
+ def index():
8
+ profile_info = None
9
+ error = None
10
+ if request.method == 'POST':
11
+ target_user = request.form['username']
12
+ L = instaloader.Instaloader()
13
+ try:
14
+ profile = instaloader.Profile.from_username(L.context, target_user)
15
+ profile_info = {
16
+ 'username': profile.username,
17
+ 'full_name': profile.full_name,
18
+ 'bio': profile.biography,
19
+ 'followers': profile.followers,
20
+ 'following': profile.followees,
21
+ 'num_posts': profile.mediacount,
22
+ 'profile_pic_url': profile.profile_pic_url
23
+ }
24
+ except instaloader.exceptions.ProfileNotExistsException:
25
+ error = "Profile not found."
26
+ except Exception as e:
27
+ error = str(e)
28
+
29
+ return render_template('index.html', profile_info=profile_info, error=error)
30
+
31
+ if __name__ == '__main__':
32
+ app.run(host='0.0.0.0', port=7860)