-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunthis
More file actions
48 lines (41 loc) · 1.08 KB
/
Copy pathrunthis
File metadata and controls
48 lines (41 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os
# Define the structure
structure = {
"templates/nodejs": [
{"name": "package.json", "content": '''{
"name": "nodejs-template",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "node index.js"
}
}'''},
{"name": "index.js", "content": '''const express = require('express');
const app = express();
const port = 3000;
app.get('/', (req, res) => {
res.send('Hello, Node.js!');
});
app.listen(port, () => {
console.log(`Server running on http://localhost:${port}`);
});'''},
],
"templates/fastapi": [
{"name": "main.py", "content": '''from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello, FastAPI!"}
'''},
{"name": "requirements.txt", "content": '''fastapi
uvicorn
'''},
],
}
# Create directories and files
for folder, files in structure.items():
os.makedirs(folder, exist_ok=True)
for file in files:
with open(os.path.join(folder, file["name"]), "w") as f:
f.write(file["content"])
print("Template structure created successfully.")