Update myapp.py
Browse files
myapp.py
CHANGED
@@ -6,8 +6,8 @@ from diffusers.pipelines.stable_diffusion import StableDiffusionSafetyChecker
|
|
6 |
import torch
|
7 |
import io
|
8 |
|
9 |
-
|
10 |
-
CORS(
|
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 |
-
@
|
28 |
def home():
|
29 |
-
return "Stable Diffusion API is running!"
|
30 |
|
31 |
-
@
|
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 |
-
|
|
|
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
|