⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.1
Server IP:
185.238.29.86
Server:
Linux server2 6.8.12-6-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.12-6 (2024-12-19T19:05Z) x86_64
Server Software:
nginx/1.18.0
PHP Version:
8.1.31
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
python
/
openai
/
View File Name :
index.js
import OpenAIApi from "openai"; import express from "express" import bodyParser from "body-parser"; import dotenv from "dotenv"; import axios from "axios" dotenv.config() const endpoint = 'https://sinomaxx.de/openai'; const app = express(); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); app.post('/', async (req, res) => { const gelen = req.body const db = gelen.db const table = gelen.table const konu = gelen.konu const title= (await uret(konu,"blog bağlığı")).content const content= (await uret(konu,"blog yazısı")).content const image= (await uret(konu,"blog resimi")).content //console.log(cevap.content) const obj = { "title":title, "content":content, "image":image } const ekle =await sendPostRequest(obj) res.json(ekle) }) app.listen(process.env.PORT) async function uret(konu,tip) { const openai = new OpenAIApi({apiKey: process.env.OPENAI_API_KEY}); const soru = konu.toString() + " ile ilgili bir " + tip.toString() + " oluştur" const chatCompletion = await openai.chat.completions.create({ model: "gpt-3.5-turbo", messages: [{"role": "user", "content": soru}], }); return (chatCompletion.choices[0].message); } async function sendPostRequest(obj,image=null) { const formData = new FormData(); if (image!=null){ formData.append('image', image); } formData.append('title', obj.title); formData.append('status', 1); formData.append('content', obj.content); formData.append('bcategory_id', 1); formData.append('language_id', 1); formData.append('meta_keywords', obj.meta_keywords); formData.append('meta_description', obj.meta_description); try { const response = await axios.post(endpoint, formData); console.log('Başarılı:', response.data); return response.data; // Yanıtı döndür } catch (error) { //console.error('Hata:', error.response ? error.response.data : error.message); throw error; // Hata durumunda hata yeniden fırlat } }