create-miniprogram-scaffold 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,26 +1,30 @@
1
1
  {
2
2
  "name": "create-miniprogram-scaffold",
3
- "version": "1.0.3",
4
- "description": "Create Taro + Go mini program projects",
3
+ "version": "1.0.5",
4
+ "description": "Create Taro + Go/Python mini program projects",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/hk029/miniprogram-scaffold.git"
8
8
  },
9
- "main": "index.js",
9
+
10
10
  "files": ["bin", "templates"],
11
11
  "bin": {
12
12
  "create-miniprogram-scaffold": "./bin/cli.js"
13
13
  },
14
14
  "scripts": {
15
- "test": "echo \"Error: no test specified\" && exit 1"
15
+ "build": "esbuild src/index.js --bundle --platform=node --format=cjs --outfile=bin/cli.js",
16
+ "dev": "esbuild src/index.js --bundle --platform=node --format=cjs --outfile=bin/cli.js --watch"
16
17
  },
17
- "keywords": ["scaffold", "taro", "go", "mini-program"],
18
+ "keywords": ["scaffold", "taro", "go", "python", "mini-program"],
18
19
  "author": "",
19
20
  "license": "MIT",
20
21
  "dependencies": {
22
+ "chalk": "^4.1.2",
21
23
  "commander": "^11.0.0",
22
- "inquirer": "^8.2.0",
23
24
  "fs-extra": "^11.1.0",
24
- "chalk": "^4.1.2"
25
+ "inquirer": "^8.2.0"
26
+ },
27
+ "devDependencies": {
28
+ "esbuild": "^0.21.0"
25
29
  }
26
- }
30
+ }
@@ -0,0 +1 @@
1
+ PORT=8080
@@ -0,0 +1,10 @@
1
+ .PHONY: install dev run
2
+
3
+ install:
4
+ pip install -r requirements.txt
5
+
6
+ dev:
7
+ uvicorn main:app --reload --port $(or $(PORT),8080)
8
+
9
+ run:
10
+ uvicorn main:app --port $(or $(PORT),8080)
@@ -0,0 +1,29 @@
1
+ # Python FastAPI Server
2
+
3
+ ## Quick Start
4
+
5
+ ```bash
6
+ pip install -r requirements.txt
7
+ python main.py
8
+ ```
9
+
10
+ Or with make:
11
+
12
+ ```bash
13
+ make install
14
+ make dev
15
+ ```
16
+
17
+ Server runs on http://localhost:8080
18
+
19
+ ## API Endpoints
20
+
21
+ | Method | Path | Description |
22
+ |--------|------|-------------|
23
+ | GET | /api/health | Health check |
24
+ | GET | /api/hello | Hello World |
25
+ | POST | /api/hello | Hello with name |
26
+
27
+ ## Docs
28
+
29
+ FastAPI 自动生成文档:http://localhost:8080/docs
@@ -0,0 +1,57 @@
1
+ from fastapi import FastAPI
2
+ from fastapi.middleware.cors import CORSMiddleware
3
+ from pydantic import BaseModel
4
+ from dotenv import load_dotenv
5
+ import os
6
+ from datetime import datetime
7
+
8
+ load_dotenv()
9
+
10
+ app = FastAPI(title="Mini Scaffold API")
11
+
12
+ app.add_middleware(
13
+ CORSMiddleware,
14
+ allow_origins=["*"],
15
+ allow_methods=["*"],
16
+ allow_headers=["*"],
17
+ )
18
+
19
+
20
+ @app.get("/api/health")
21
+ def health():
22
+ return {"code": 0, "message": "OK", "data": {"status": "healthy"}}
23
+
24
+
25
+ @app.get("/api/hello")
26
+ def hello():
27
+ return {
28
+ "code": 0,
29
+ "message": "success",
30
+ "data": {
31
+ "greeting": "Hello, World! 来自 Python 后端",
32
+ "timestamp": datetime.now().isoformat(),
33
+ "version": "1.0.0",
34
+ },
35
+ }
36
+
37
+
38
+ class HelloRequest(BaseModel):
39
+ name: str = "World"
40
+
41
+
42
+ @app.post("/api/hello")
43
+ def hello_name(req: HelloRequest):
44
+ return {
45
+ "code": 0,
46
+ "message": "success",
47
+ "data": {
48
+ "greeting": f"Hello, {req.name}! 来自 Python 后端",
49
+ "timestamp": datetime.now().isoformat(),
50
+ },
51
+ }
52
+
53
+
54
+ if __name__ == "__main__":
55
+ import uvicorn
56
+ port = int(os.getenv("PORT", "8080"))
57
+ uvicorn.run("main:app", host="0.0.0.0", port=port, reload=True)
@@ -0,0 +1,3 @@
1
+ fastapi==0.111.0
2
+ uvicorn[standard]==0.30.1
3
+ python-dotenv==1.0.1