randydev commited on
Commit
2a1da11
·
verified ·
1 Parent(s): 6150161

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +23 -0
index.js CHANGED
@@ -26,6 +26,9 @@ import * as swaggerDocs from './swagger.js';
26
  import * as cheerio from 'cheerio';
27
  import * as lifestyle from './lifestyle.js';
28
 
 
 
 
29
  import { OpenaiRes, tebakgambar, AnimeHentai } from './scrapper.js';
30
  import { GeminiResponse } from './googleGemini.js';
31
  import { CheckMilWare } from './midware.js';
@@ -88,4 +91,24 @@ app.get('/api/v1/gpt-old', async (req, res) => {
88
  }
89
  });
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  lifestyle.startServer(app);
 
26
  import * as cheerio from 'cheerio';
27
  import * as lifestyle from './lifestyle.js';
28
 
29
+ import sharp from "sharp";
30
+ import { Readable } from "stream";
31
+ import { schellwithflux } from './fluxai.js';
32
  import { OpenaiRes, tebakgambar, AnimeHentai } from './scrapper.js';
33
  import { GeminiResponse } from './googleGemini.js';
34
  import { CheckMilWare } from './midware.js';
 
91
  }
92
  });
93
 
94
+ app.get("/api/v1/fluxai-ai", async (req, res) => {
95
+ try {
96
+ const query = req.body.query;
97
+ const imageBytes = await schellwithflux(query);
98
+
99
+ if (!imageBytes) {
100
+ return res.status(500).json({ error: "Failed to fetch image bytes" });
101
+ }
102
+ const processedImage = await sharp(imageBytes)
103
+ .jpeg()
104
+ .toBuffer();
105
+ res.set("Content-Type", "image/jpeg");
106
+ const stream = Readable.from(processedImage);
107
+ stream.pipe(res);
108
+ } catch (error) {
109
+ console.error("Error processing image:", error.message);
110
+ res.status(500).json({ error: "Internal server error" });
111
+ }
112
+ });
113
+
114
  lifestyle.startServer(app);