Download src/index.ts from launch-calcium/Gallery-Copper-Typescript: direct link, hf CLI and curl.
- Browser
- Download file 1.34 kB
-
https://huggingface.co/spaces/launch-calcium/Gallery-Copper-Typescript/resolve/main/src/index.ts
- Command line
-
hf download hf://spaces/launch-calcium/Gallery-Copper-Typescript/src/index.ts
-
curl -L -o index.ts https://huggingface.co/spaces/launch-calcium/Gallery-Copper-Typescript/resolve/main/src/index.ts
1.34 kB
| import express from 'express'; | |
| import session from 'express-session'; | |
| import cookieParser from 'cookie-parser'; | |
| import path from 'path'; | |
| import { initDatabase, getConfig } from './db'; | |
| import { galleryRouter } from './gallery'; | |
| import { authRouter } from './auth'; | |
| import { adminRouter } from './admin'; | |
| const app = express(); | |
| const PORT = process.env.PORT || 8080; | |
| initDatabase(); | |
| app.set('views', path.join(__dirname, '../views')); | |
| app.set('view engine', 'ejs'); | |
| app.use(express.json()); | |
| app.use(express.urlencoded({ extended: true })); | |
| app.use(cookieParser()); | |
| app.use( | |
| session({ | |
| secret: 'coppermine_ts_secret_key_12345', | |
| resave: false, | |
| saveUninitialized: false, | |
| cookie: { maxAge: 24 * 60 * 60 * 1000 } | |
| }) | |
| ); | |
| app.use(express.static(path.join(__dirname, '../public'))); | |
| app.use('/uploads', express.static(path.join(__dirname, '../uploads'))); | |
| app.use((req, res, next) => { | |
| res.locals.config = getConfig(); | |
| res.locals.user = (req.session as any).user || null; | |
| next(); | |
| }); | |
| app.get('/login', (req, res) => res.render('login', { title: 'Login' })); | |
| app.get('/register', (req, res) => res.render('register', { title: 'Register' })); | |
| app.use('/auth', authRouter); | |
| app.use('/', galleryRouter); | |
| app.use('/admin', adminRouter); | |
| app.listen(PORT, () => { | |
| console.log(`Server is running on port ${PORT}`); | |
| }); | |