Spaces:
Build error
Build error
Download process.env.PORT from irelandcuca/HumanMaster6HD: direct link, hf CLI and curl.
- Browser
- Download file 2.27 kB
-
https://huggingface.co/spaces/irelandcuca/HumanMaster6HD/resolve/main/process.env.PORT
- Command line
-
hf download hf://spaces/irelandcuca/HumanMaster6HD/process.env.PORT
-
curl -L -o process.env.PORT https://huggingface.co/spaces/irelandcuca/HumanMaster6HD/resolve/main/process.env.PORT
2.27 kB
| const express = require('express'); | |
| const { Pool } = require('pg'); | |
| const session = require('express-session'); | |
| const pgSession = require('connect-pg-simple')(session); | |
| require('dotenv').config(); | |
| const app = express(); | |
| const PORT = process.env.PORT || 7860; | |
| const pool = new Pool({ | |
| connectionString: process.env.DATABASE_URL, | |
| ssl: { rejectUnauthorized: false } | |
| }); | |
| app.use(express.json()); | |
| app.use(session({ | |
| store: new pgSession({ | |
| pool: pool, | |
| tableName: 'sessions' | |
| }), | |
| secret: process.env.SESSION_SECRET || 'ucdm_secure_secret_key', | |
| resave: false, | |
| saveUninitialized: false, | |
| cookie: { maxAge: 30 * 24 * 60 * 60 * 1000, httpOnly: true } | |
| })); | |
| // Create or update a user profile | |
| app.post('/api/users', async (req, res) => { | |
| const { id, email, first_name, last_name, profile_image_url } = req.body; | |
| try { | |
| const result = await pool.query( | |
| `INSERT INTO users (id, email, first_name, last_name, profile_image_url) | |
| VALUES (COALESCE(, gen_random_uuid()::text), , , , ) | |
| ON CONFLICT (email) DO UPDATE | |
| SET first_name = EXCLUDED.first_name, last_name = EXCLUDED.last_name, updated_at = now() | |
| RETURNING *`, | |
| [id, email, first_name, last_name, profile_image_url] | |
| ); | |
| res.status(201).json({ success: true, user: result.rows[0] }); | |
| } catch (err) { | |
| res.status(500).json({ error: err.message }); | |
| } | |
| }); | |
| // Save a processing log entry | |
| app.post('/api/logs', async (req, res) => { | |
| const { user_id, preset, original_filename, output_filename } = req.body; | |
| try { | |
| const result = await pool.query( | |
| `INSERT INTO usage_logs (user_id, preset, original_filename, output_filename) | |
| VALUES (, , , ) RETURNING *`, | |
| [user_id, preset, original_filename, output_filename] | |
| ); | |
| res.status(201).json({ success: true, log: result.rows[0] }); | |
| } catch (err) { | |
| res.status(500).json({ error: err.message }); | |
| } | |
| }); | |
| app.get('/', (req, res) => { | |
| res.send('Database Core Engine running smoothly on Hugging Face Docker Core.'); | |
| }); | |
| app.listen(PORT, () => { | |
| console.log(`Server actively routing pipelines on port ${PORT}`); | |
| }); | |