instagram-scraper icon indicating copy to clipboard operation
instagram-scraper copied to clipboard

Internal Server Error 500

Open zekkontro opened this issue 3 years ago • 2 comments

same code works on windows but i get 500 Internal Server error on linux. my codes are as below.

`import instagram_scraper as insta
  from flask import Flask, jsonify
  from flask import make_response
  from flask import request
  
  key = "SECRET KEY"
  app = Flask(__name__, static_url_path="")
  
  
  instagram = insta.InstagramScraper()
  
  
  
  @app.route("/insta/v1/getDatasByUsername", methods=['GET'])
  def getDatasByUsername():
      if(request.args.get("key") == key):
          username = request.args.get("username")
          medias = instagram.get_medias(username=username, count=20)
          account = instagram.get_account(username)
          post = list()
          for i in medias:
              post.append( {"image": i.get_image_high_resolution_url(), "created": i.get_created_time(), "likes_count": i.get_likes_count(), "comments": i.get_comments()})
              print(i.get_image_high_resolution_url())
  
          return make_response(jsonify({"profile-image": account.get_profile_pic_url_hd(), "username": username, "full-name": account.get_full_name(), "biogrophy": account.get_biography(), "follows_count": account.get_follows_count(), "followed_by_count": account.get_followed_by_count(), "bussiness_category_name": account.get_business_category_name(), "business_email": account.get_business_email(), "business_phone": account.get_business_phone_number(),"posts": post}), 200)
      
      else:
          return make_response(jsonify({"error" : "API Key is not valid"}), 404)
  
  
  @app.errorhandler(404)
  def not_found(error):
      return make_response(jsonify({'HTTP 404 Error': 'The content you looks for does not exist. Please check your request.'}), 404)
  
  
  if __name__ == '__main__':
      from waitress import serve
      serve(app, host="127.0.0.1", port=5000)
      app.run(debug=True)  # !flask/bin/python

`

zekkontro avatar Jul 02 '21 20:07 zekkontro