-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
87 lines (72 loc) · 2.19 KB
/
app.py
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from flask import Flask, jsonify
app = Flask(__name__)
from datetime import datetime
import re
import amelia
import configparser
def AnsiPos(subStr, fullStr):
result = [pos for pos, char in enumerate(fullStr) if char == subStr]
return result
#trueVer.bugFix.checkpoint.try
ver = '0.1.2.6'
conn = []
cnfer = configparser.ConfigParser()
cnfer.sections()
cnfer.read('config.cnf')
if 'DB' in cnfer:
conn.append(cnfer['DB']['host'])
conn.append(cnfer['DB']['user'])
conn.append(cnfer['DB']['pass'])
conn.append(cnfer['DB']['db'])
@app.route("/", methods=['GET', 'POST', 'PUT'])
def home():
return "Up!"
@app.route("/ver", methods=['GET', 'POST', 'PUT'])
def verN():
return ver
@app.route("/isConnected", methods=['GET', 'POST', 'PUT'])
def alive():
return amelia.isAlive(conn)
@app.route("/put/<Aparam>", methods=['GET', 'POST', 'PUT'])
def openSP(Aparam):
lister = Aparam.split('@')
Aproc = lister[0]
lister.pop(0)
if len(lister) == 0:
lister = ()
content = amelia.ameliaGoProcOpen(conn, Aproc, lister)
content = jsonify(content)
return content
@app.route("/do/<Aparam>", methods=['GET', 'POST', 'PUT'])
def execSP(Aparam):
lister = Aparam.split('@')
Aproc = lister[0]
lister.pop(0)
if len(lister) == 0:
lister = ()
content = amelia.ameliaGoProcExec(conn, Aproc, lister)
if len(AnsiPos('err', content)) == 0:
content = 'ok'
content = jsonify(content)
return content
@app.route("/testeJson/", methods=['GET', 'POST', 'PUT'])
def teste():
content = amelia.ameliaGoOpenSql(conn, "select 8, name from test")
content = jsonify(content)
return content
@app.route("/neh")
def neh():
return 'neh'
@app.route("/putter/<Aparam>", methods=['GET', 'POST', 'PUT'])
def openSPA(Aparam):
return Aparam
@app.route("/testeInsert/<insertClause>", methods=['GET', 'POST', 'PUT'])
def testeIn(insertClause):
conexao = amelia.baseConnect('0.0.0.0', 'root', 'root', 'test')
lcursor = conexao.cursor()
query = amelia.simpleSqlExec(lcursor, "select " + insertClause)
conexao.commit()
content = jsonify(query)
return content
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000)