Init version
This commit is contained in:
commit
5692a44df1
27
app.py
Normal file
27
app.py
Normal 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
23
cfg.json
Normal 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
47744
static/css/helper.css
Normal file
File diff suppressed because it is too large
Load Diff
2404
static/css/iconfont.css
Normal file
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
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
3610
static/js/sdk.js
Normal file
File diff suppressed because one or more lines are too long
36
templates/index.html
Normal file
36
templates/index.html
Normal 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>
|
Loading…
Reference in New Issue
Block a user