loading initial state on start
This commit is contained in:
parent
2a22f14509
commit
0358a1f918
4 changed files with 124 additions and 0 deletions
54
backend/backend.py
Normal file
54
backend/backend.py
Normal file
|
@ -0,0 +1,54 @@
|
|||
import http.server
|
||||
import socketserver
|
||||
import subprocess
|
||||
from urllib.parse import urlparse, parse_qs
|
||||
|
||||
class MyHttpRequestHandler(http.server.SimpleHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
parsed_path = urlparse(self.path)
|
||||
query = parse_qs(parsed_path.query)
|
||||
print(query)
|
||||
|
||||
if 'command' in query and 'args' in query:
|
||||
self.send_response(200)
|
||||
self.send_header('Content-type', 'text/html')
|
||||
self.end_headers()
|
||||
self.wfile.write(bytes(f"command: {query['command']}, args: {query['args']}", "utf-8"))
|
||||
else:
|
||||
self.send_response(400)
|
||||
self.send_header('Content-type', 'text/html')
|
||||
self.end_headers()
|
||||
self.wfile.write(bytes("Bad request", "utf-8"))
|
||||
|
||||
PORT = 2281
|
||||
Handler = MyHttpRequestHandler
|
||||
|
||||
def compile_and_deploy_contract():
|
||||
# User
|
||||
user_compile_command = "neo-go contract compile -i User/user.go -c User/user.yml -m User/user.json"
|
||||
subprocess.run(user_compile_command, shell=True, check=True)
|
||||
|
||||
user_deploy_command = "neo-go contract deploy -i User/user.nef -w /home/ftmi-krasotka/Desktop/frostfs_test/frostfs-aio/morph/node-wallet.json -r http://localhost:30333 -m User/user.json"
|
||||
subprocess.run(user_deploy_command, shell=True, check=True)
|
||||
|
||||
# Post
|
||||
post_compile_command = "neo-go contract compile -i Post/post_contract.go -c Post/post_contract.yml -m Post/post_contract.json"
|
||||
subprocess.run(post_compile_command, shell=True, check=True)
|
||||
|
||||
post_deploy_command = "neo-go contract deploy -i Post/post_contract.nef -w /home/ftmi-krasotka/Desktop/frostfs_test/frostfs-aio/morph/node-wallet.json -r http://localhost:30333 -m Post/post_contract.json"
|
||||
subprocess.run(post_deploy_command, shell=True, check=True)
|
||||
|
||||
# Comment
|
||||
comment_compile_command = "neo-go contract compile -i Comment/comment.go -c Comment/comment.yml -m Comment/comment.json"
|
||||
subprocess.run(comment_compile_command, shell=True, check=True)
|
||||
|
||||
comment_deploy_command = "neo-go contract deploy -i Comment/comment.nef -w /home/ftmi-krasotka/Desktop/frostfs_test/frostfs-aio/morph/node-wallet.json -r http://localhost:30333 -m Comment/comment.json"
|
||||
subprocess.run(comment_deploy_command, shell=True, check=True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
compile_and_deploy_contract()
|
||||
|
||||
with socketserver.TCPServer(("", PORT), Handler) as httpd:
|
||||
print("Сервер запущен на порту", PORT)
|
||||
httpd.serve_forever()
|
||||
httpd.server_close()
|
62
backend/edit_route.py
Normal file
62
backend/edit_route.py
Normal file
|
@ -0,0 +1,62 @@
|
|||
import json
|
||||
|
||||
|
||||
route = {
|
||||
"1": {
|
||||
"command": "neo-go wallet init",
|
||||
"flags": {
|
||||
"wallet": "wallet file name",
|
||||
"account": "create new account"
|
||||
}
|
||||
},
|
||||
"2": {
|
||||
"command": "neo-go wallet dump-keys",
|
||||
"flags": {
|
||||
"wallet": "wallet file name",
|
||||
}
|
||||
},
|
||||
"3": {
|
||||
"command": "neo-go wallet nep17 balance",
|
||||
"flags": {
|
||||
"wallet": "wallet file name",
|
||||
}
|
||||
},
|
||||
"4": {
|
||||
"command": "neo-go wallet nep17 transfer",
|
||||
"flags": {
|
||||
"wallet": "wallet file name(wallet from which transfer is made)",
|
||||
"from": "hash of wallet from which transfer is made",
|
||||
"to" : "hash of wallet to which transfer is made",
|
||||
"amount": "gas transfer amount",
|
||||
"token": "token for transfer NEO/GAS",
|
||||
}
|
||||
},
|
||||
"5": {
|
||||
"command": "neo-go contract compile",
|
||||
"flags": {
|
||||
"in": "smart contract file name(*.go)",
|
||||
"manifest": "contract manifest file name(*.json)",
|
||||
"contract_config" : "contract config file name(*.yml)",
|
||||
}
|
||||
},
|
||||
"6": {
|
||||
"command": "neo-go contract deploy",
|
||||
"flags": {
|
||||
"wallet": "wallet file name",
|
||||
"in": "compiled smart contract file name(*.nef)",
|
||||
"manifest" : "manifest file name(*.json)",
|
||||
}
|
||||
},
|
||||
"7": {
|
||||
"command": "neo-go contract invokefunction",
|
||||
"flags": {
|
||||
"wallet": "wallet file name",
|
||||
"contract_hash": "hash of contract",
|
||||
"func_name": "name of invoked func",
|
||||
"parameters": "list([]) of func parameters"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
with open("route.json", "w") as f:
|
||||
f.write(json.dumps(route))
|
7
backend/req_test.py
Normal file
7
backend/req_test.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
import requests
|
||||
|
||||
# Отправляем GET запрос на сервер
|
||||
response = requests.get('http://localhost:2281', params={"command": 0, "args": {"amount_1": 1, "amount": 1}})
|
||||
|
||||
# Выводим ответ от сервера
|
||||
print('Ответ от сервера:', response.text)
|
1
backend/route.json
Normal file
1
backend/route.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"1": {"command": "neo-go wallet init", "flags": {"wallet": "wallet file name", "account": "create new account"}}, "2": {"command": "neo-go wallet dump-keys", "flags": {"wallet": "wallet file name"}}, "3": {"command": "neo-go wallet nep17 balance", "flags": {"wallet": "wallet file name"}}, "4": {"command": "neo-go wallet nep17 transfer", "flags": {"wallet": "wallet file name(wallet from which transfer is made)", "from": "hash of wallet from which transfer is made", "to": "hash of wallet to which transfer is made", "amount": "gas transfer amount", "token": "token for transfer NEO/GAS"}}, "5": {"command": "neo-go contract compile", "flags": {"in": "smart contract file name(*.go)", "manifest": "contract manifest file name(*.json)", "contract_config": "contract config file name(*.yml)"}}, "6": {"command": "neo-go contract deploy", "flags": {"wallet": "wallet file name", "in": "compiled smart contract file name(*.nef)", "manifest": "manifest file name(*.json)"}}, "7": {"command": "neo-go contract invokefunction", "flags": {"wallet": "wallet file name", "contract_hash": "hash of contract", "func_name": "name of invoked func", "parameters": "list([]) of func parameters"}}}
|
Loading…
Reference in a new issue