Flask-test / app.py
lelafav502's picture
Rename main (2).py to app.py
27d1080 verified
raw
history blame contribute delete
No virus
807 Bytes
from flask import Flask, request, jsonify
from gradio_client import Client
app = Flask(__name__)
@app.route('/', methods=['GET'])
def get_prediction():
# Extract data for prediction
prompt = request.args.get("prompt")
negative_prompt = request.args.get("negative_prompt")
width = int(request.args.get("width"))
height = int(request.args.get("height"))
# Make prediction using Gradio Client
client = Client("https://ddosxd-realvisxl.hf.space/--replicas/flm7z/")
result = client.predict(
prompt,
negative_prompt,
True,
0,
width,
height,
7,
True,
api_name="/run"
)
# Return the result as JSON response
return jsonify(result)
if __name__ == '__main__':
app.run(debug=True, port=8080)