Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,35 @@ import time
|
|
| 5 |
|
| 6 |
app = Flask(__name__)
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
def generate_fake_stream(image_url):
|
| 11 |
chunks = [
|
|
|
|
| 5 |
|
| 6 |
app = Flask(__name__)
|
| 7 |
|
| 8 |
+
def get_token():
|
| 9 |
+
url = "https://fluxaiweb.com/flux/getToken"
|
| 10 |
+
response = requests.get(url)
|
| 11 |
+
if response.status_code == 200:
|
| 12 |
+
response_json = response.json()
|
| 13 |
+
return response_json.get("data", {}).get("token")
|
| 14 |
+
return None
|
| 15 |
+
|
| 16 |
+
def req_flux(token, prompt_value, aspect_ratio="1:1", output_format="webp", num_outputs=1, output_quality=90):
|
| 17 |
+
url = "https://fluxaiweb.com/flux/generateImage"
|
| 18 |
+
payload = {
|
| 19 |
+
"prompt": prompt_value,
|
| 20 |
+
"aspectRatio": aspect_ratio,
|
| 21 |
+
"outputFormat": output_format,
|
| 22 |
+
"numOutputs": num_outputs,
|
| 23 |
+
"outputQuality": output_quality
|
| 24 |
+
}
|
| 25 |
+
headers = {
|
| 26 |
+
'Content-Type': 'application/json',
|
| 27 |
+
'token': token
|
| 28 |
+
}
|
| 29 |
+
try:
|
| 30 |
+
response = requests.post(url, headers=headers, json=payload)
|
| 31 |
+
response.raise_for_status()
|
| 32 |
+
data = response.json()
|
| 33 |
+
return data.get("data", {}).get("image")
|
| 34 |
+
except requests.exceptions.RequestException as e:
|
| 35 |
+
print(f"Error making request: {e}")
|
| 36 |
+
return None
|
| 37 |
|
| 38 |
def generate_fake_stream(image_url):
|
| 39 |
chunks = [
|