Geek7 commited on
Commit
ec20299
1 Parent(s): 74fabd0

Update myapp.py

Browse files
Files changed (1) hide show
  1. myapp.py +4 -4
myapp.py CHANGED
@@ -5,8 +5,8 @@ from huggingface_hub import InferenceClient
5
  from io import BytesIO # For converting image to bytes
6
 
7
  # Initialize the Flask app
8
- app = Flask(__name__)
9
- CORS(app) # Enable CORS for all routes
10
 
11
  # Initialize the InferenceClient with your Hugging Face token
12
  HF_TOKEN = os.environ.get("HF_TOKEN") # Ensure to set your Hugging Face token in the environment
@@ -22,7 +22,7 @@ def generate_image(prompt, seed=1, model="prompthero/openjourney-v4"):
22
  return None
23
 
24
  # Flask route for the API endpoint
25
- @app.route('/generate_image', methods=['POST'])
26
  def generate_api():
27
  data = request.get_json()
28
 
@@ -52,4 +52,4 @@ def generate_api():
52
 
53
  # Add this block to make sure your app runs when called
54
  if __name__ == "__main__":
55
- app.run(host='0.0.0.0', port=7860) # Run directly if needed for testing
 
5
  from io import BytesIO # For converting image to bytes
6
 
7
  # Initialize the Flask app
8
+ myapp = Flask(__name__)
9
+ CORS(myapp) # Enable CORS for all routes
10
 
11
  # Initialize the InferenceClient with your Hugging Face token
12
  HF_TOKEN = os.environ.get("HF_TOKEN") # Ensure to set your Hugging Face token in the environment
 
22
  return None
23
 
24
  # Flask route for the API endpoint
25
+ @myapp.route('/generate_image', methods=['POST'])
26
  def generate_api():
27
  data = request.get_json()
28
 
 
52
 
53
  # Add this block to make sure your app runs when called
54
  if __name__ == "__main__":
55
+ myapp.run(host='0.0.0.0', port=7860) # Run directly if needed for testing