python-amis
import random
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from fastapi.responses import HTMLResponse
from fastapi import Request
from fastapi.exceptions import HTTPException
from amis.amis import amis
import json
app = FastAPI()
@app.get("/")
def home():
page = amis().Page().body([
amis().Form()
.api("/add")
.title("登录")
.rules([
{"rule": "data.usernmae", "message": "用户名 为空", "name": ["username"]},
{"rule": "data.password", "message": "密码 为空", "name": "password"}
])
.body([
amis().InputText().label("用户名").name('username'),
amis().InputPassword().label("密码").name('password'),
])
.actions([
amis().Button().label("重置").actionType("reset"),
amis().Button().label("保存").actionType("submit").level("primary")
])
])
amis_html = page.to_html()
return HTMLResponse(content=amis_html, status_code=200)
@app.get("/table")
def home():
page = (amis().Page()
.type("service")
.api("/get_table")
.body([
amis().CRUD().title("表格1").source("$rows").columns([
{"name": "id", "label": "ID"},
{"name": "name", "label": "姓名"}
])
]))
amis_html = page.to_html()
return HTMLResponse(content=amis_html, status_code=200)
@app.get("/get_table")
def get_table():
# 随机生成name列表
names = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u",
"v", "w", "x", "y", "z"]
# 随机生成id列表
ids = [i for i in range(1, 101)]
# 随机生成name列表
names = random.choices(names, k=100)
rows = []
for i in range(100):
rows.append({
"name": names[i],
"id": ids[i]
})
return {
"status": 0,
"msg": "ok",
"data": {
"count": len(rows),
"rows": rows
}
}
@app.api_route("/{path:path}", methods=["POST", "PUT", "DELETE"])
async def handle_all_requests(request: Request):
json_data = await request.json()
print(f"请求地址: {request.url}")
print(f"请求数据: {json_data}")
message = json.dumps({
"json_data": json_data,
"url": str(request.url),
"method": request.method
})
return {
"status": 0,
"message": message,
"mydata": message,
}
# 将public目录挂载为静态文件目录
app.mount("/jssdk", StaticFiles(directory="public/jssdk", html=True), name="static")
if __name__ == "__main__":
import uvicorn
uvicorn.run("main:app", host="0.0.0.0", port=5001, reload=True)
Metadata
Release files for python-amis 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| python_amis-0.0.3.tar.gz | 192.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| python_amis-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 674.0 kB
Release files / python_amis-0.0.3.tar.gz
| Download URL | python_amis-0.0.3.tar.gz |
|---|---|
| Size | 192.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a8d97004803ef1678b8d1c65b94ccf44d8673edacab5bae65dba7725cc5feb82
|
|
BLAKE2b-256 checksum How to use checksums |
f9bb79adbbc92e7235abdbfdd9ff70ce27fdbb1a333e1dc6e32605672b32667e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.20
|
Release files / python_amis-0.0.3-py3-none-any.whl
| Download URL | python_amis-0.0.3-py3-none-any.whl |
|---|---|
| Size | 481.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e5bb56f4b266f7fa711b1a911e7c76757f66689b6353c855728874f822b6b8c0
|
|
BLAKE2b-256 checksum How to use checksums |
9cec0cd7209c33123b15a99d0d58e96eebe4889c641804379e144a436d4e8063
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.20
|
Security for python-amis 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.