Download server.js from Neilqwe/eu4: direct link, hf CLI and curl.
- Browser
- Download file 1.71 kB
-
https://huggingface.co/spaces/Neilqwe/eu4/resolve/main/server.js
- Command line
-
hf download hf://spaces/Neilqwe/eu4/server.js
-
curl -L -o server.js https://huggingface.co/spaces/Neilqwe/eu4/resolve/main/server.js
1.71 kB
| const express = require('express'); | |
| const multer = require('multer'); | |
| const fs = require('fs'); | |
| const axios = require('axios'); | |
| const app = express(); | |
| const upload = multer({ dest: 'uploads/' }); | |
| // PDX Tools API kullanıcı bilgileri | |
| const PDX_USER = 'yourUserId'; // Buraya kendi kullanıcı ID'nı yaz | |
| const PDX_API_KEY = 'yourApiKey'; // Buraya kendi API anahtarını yaz | |
| app.use(express.static('public')); | |
| app.post('/upload', upload.single('savefile'), async (req, res) => { | |
| try { | |
| if (!req.file) return res.status(400).send('Dosya seçilmedi.'); | |
| const filePath = req.file.path; | |
| const originalName = req.file.originalname; | |
| const fileData = fs.readFileSync(filePath); | |
| const response = await axios.post( | |
| 'https://pdx.tools/api/saves', | |
| fileData, | |
| { | |
| headers: { | |
| 'pdx-tools-filename': originalName, | |
| 'Content-Type': 'application/zip', // Eğer dosyan zip değilse burayı değiştirebilirsin | |
| }, | |
| auth: { | |
| username: PDX_USER, | |
| password: PDX_API_KEY, | |
| }, | |
| maxContentLength: Infinity, | |
| maxBodyLength: Infinity, | |
| } | |
| ); | |
| const saveId = response.data.save_id; | |
| fs.unlinkSync(filePath); // Geçici dosyayı sil | |
| // Kullanıcıyı PDX Tools analiz sayfasına yönlendir | |
| res.redirect(`https://pdx.tools/eu4/saves/${saveId}`); | |
| } catch (error) { | |
| console.error(error.response?.data || error.message); | |
| res.status(500).send('Yükleme veya analiz sırasında hata oluştu.'); | |
| } | |
| }); | |
| const PORT = 3000; | |
| app.listen(PORT, () => { | |
| console.log(`Sunucu http://localhost:${PORT} adresinde çalışıyor`); | |
| }); | |