add backend files
This commit is contained in:
parent
2b4b363982
commit
1eca8232e0
4 changed files with 98 additions and 0 deletions
28
backend/backend.py
Normal file
28
backend/backend.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
import http.server
|
||||
import socketserver
|
||||
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
|
||||
|
||||
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