Spaces:
Sleeping
Sleeping
Create app.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839from flask import Flask, render_template, request, jsonifyimport osimport cv2import base64import requests
app = Flask(__name__)
# Instagram credentials (use your Instagram bot or automation method here)INSTAGRAM_USERNAME = 'your_username'INSTAGRAM_PASSWORD = 'your_password'
@app.route('/')def index(): return render_template('index.html')
@app.route('/capture', methods=['POST'])def capture(): image_data = request.form['image'] # Decode the image from base64 to save it img_data = base64.b64decode(image_data.split(',')[1]) with open("static/images/captured_image.jpg", "wb") as f: f.write(img_data) return jsonify({"message": "Image captured!"})
@app.route('/post_to_instagram', methods=['POST'])def post_to_instagram(): # Assuming you're using instabot for posting to Instagram from instabot import Bot bot = Bot() bot.login(username=INSTAGRAM_USERNAME, password=INSTAGRAM_PASSWORD) image_path = "static/images/captured_image.jpg" bot.upload_photo(image_path, caption="Your Image Caption Here") return jsonify({"message": "Image posted to Instagram!"})
if __name__ == '__main__': app.run(debug=True)app.pyAdded+39