goldenbrown commited on
Commit
93ce3d2
1 Parent(s): 4d76dee

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import requests
3
+ from flask import Flask, request, jsonify
4
+
5
+ app = Flask(__name__)
6
+
7
+ # Get Hugging Face API key from environment variables
8
+ API_URL = "https://api-inference.huggingface.co/models/Organika/sdxl-detector"
9
+ API_KEY = os.getenv('HF_API_TOKEN')
10
+
11
+ @app.route('/check_image', methods=['POST'])
12
+ def check_image():
13
+ # Get image data from the request
14
+ image = request.files['image'].read()
15
+ headers = {
16
+ "Authorization": f"Bearer {API_KEY}"
17
+ }
18
+ response = requests.post(API_URL, headers=headers, files={"inputs": image})
19
+ return jsonify(response.json())
20
+
21
+ if __name__ == '__main__':
22
+ app.run(host='0.0.0.0', port=7860)