Init version

This commit is contained in:
murmur 2024-07-02 23:47:32 +08:00
commit 5692a44df1
8 changed files with 54137 additions and 0 deletions

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# Demo程序
基于Pyhton和Flask的demo程序

27
app.py Normal file
View File

@ -0,0 +1,27 @@
from flask import Flask, jsonify, render_template,request
import json
app = Flask(__name__)
@app.route('/api/config')
def get_config():
with open('cfg.json', 'r', encoding='utf-8') as f:
config = json.load(f)
return jsonify(config)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/saveForm', methods=['POST'])
def submit():
username = request.json.get('name')
password = request.json.get('email')
# 执行提交逻辑
print(username,password)
return jsonify({"code": 0, "msg": "恭喜,注册成功!"})
if __name__ == '__main__':
app.run()

23
cfg.json Normal file
View File

@ -0,0 +1,23 @@
{
"body": {
"api": "/saveForm",
"body": [
{
"label": "Name",
"name": "name",
"type": "input-text",
"required": true
},
{
"label": "Email邮箱",
"name": "email",
"type": "input-email",
"required": true
}
],
"mode": "horizontal",
"type": "form"
},
"title": "demo测试",
"type": "page"
}

47744
static/css/helper.css Normal file

File diff suppressed because it is too large Load Diff

2404
static/css/iconfont.css Normal file

File diff suppressed because one or more lines are too long

291
static/css/sdk.css Normal file

File diff suppressed because one or more lines are too long

3610
static/js/sdk.js Normal file

File diff suppressed because one or more lines are too long

36
templates/index.html Normal file
View File

@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AMIS 示例</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/sdk.css') }}" />
</head>
<body>
<div id="root"></div>
<script src="{{ url_for('static', filename='js/sdk.js') }}"></script>
<script>
async function fetchConfig() {
try {
const response = await fetch('/api/config');
if (!response.ok) {
throw new Error('Network response was not ok ' + response.statusText);
}
const config = await response.json();
renderAmis(config);
} catch (error) {
console.error('Fetch error:', error);
}
}
function renderAmis(config) {
let amis = amisRequire('amis/embed');
amis.embed('#root', config);
}
// 获取并渲染配置
fetchConfig();
</script>
</body>
</html>