feat: 城中村租房平台 - 租客浏览、房东发布房源、图片上传
This commit is contained in:
17
app/api/districts/route.ts
Normal file
17
app/api/districts/route.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import fs from 'fs/promises';
|
||||
import path from 'path';
|
||||
|
||||
const DATA_DIR = path.join(process.cwd(), 'data');
|
||||
const DISTRICTS_FILE = path.join(DATA_DIR, 'districts.json');
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const data = await fs.readFile(DISTRICTS_FILE, 'utf-8');
|
||||
const districts = JSON.parse(data);
|
||||
return NextResponse.json({ districts });
|
||||
} catch (error) {
|
||||
console.error('Get districts error:', error);
|
||||
return NextResponse.json({ districts: [] });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user