Spaces:
Sleeping
Sleeping
File size: 1,193 Bytes
19ce28f |
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 |
from flask import Flask, render_template, request, jsonify
import os
import cv2
import base64
import 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)
|