Geek7 commited on
Commit
d3cdca9
1 Parent(s): 1674dce

Update myapp.py

Browse files
Files changed (1) hide show
  1. myapp.py +6 -6
myapp.py CHANGED
@@ -6,8 +6,8 @@ from diffusers.pipelines.stable_diffusion import StableDiffusionSafetyChecker
6
  import torch
7
  import io
8
 
9
- app = Flask(__name__)
10
- CORS(app) # Enable CORS for all routes
11
 
12
  # Load the pre-trained models
13
  repo_id = "stabilityai/stable-diffusion-2"
@@ -24,11 +24,11 @@ pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
24
  # Move pipeline to CPU
25
  pipe = pipe.to("cpu")
26
 
27
- @app.route('/')
28
  def home():
29
- return "Stable Diffusion API is running!"
30
 
31
- @app.route('/generate', methods=['POST'])
32
  def generate():
33
  prompt = request.form.get('prompt')
34
  if not prompt:
@@ -47,4 +47,4 @@ def generate():
47
  return jsonify({"error": "NSFW content detected!"}), 400
48
 
49
  if __name__ == '__main__':
50
- app.run(host="0.0.0.0", port=8080, debug=True)
 
6
  import torch
7
  import io
8
 
9
+ myapp = Flask(__name__) # Changed from app to myapp
10
+ CORS(myapp) # Enable CORS for all routes
11
 
12
  # Load the pre-trained models
13
  repo_id = "stabilityai/stable-diffusion-2"
 
24
  # Move pipeline to CPU
25
  pipe = pipe.to("cpu")
26
 
27
+ @myapp.route('/')
28
  def home():
29
+ return "Stable Diffusion API is running!" # Basic message
30
 
31
+ @myapp.route('/generate', methods=['POST'])
32
  def generate():
33
  prompt = request.form.get('prompt')
34
  if not prompt:
 
47
  return jsonify({"error": "NSFW content detected!"}), 400
48
 
49
  if __name__ == '__main__':
50
+ myapp.run(host="0.0.0.0", port=8080, debug=True) # Changed app to myapp