Merge pull request 'cringe_backend' (#10) from cringe_backend into master

Reviewed-on: https://codeberg.org/NaMe2te/Blog/pulls/10
This commit is contained in:
RustamOper05 2024-01-17 10:36:16 +00:00
commit 4858338a04

View file

@ -1,7 +1,11 @@
import http.server import http.server
import socketserver import socketserver
import subprocess import subprocess
import sys
import pexpect
from urllib.parse import urlparse, parse_qs from urllib.parse import urlparse, parse_qs
import base64
class MyHttpRequestHandler(http.server.SimpleHTTPRequestHandler): class MyHttpRequestHandler(http.server.SimpleHTTPRequestHandler):
def do_GET(self): def do_GET(self):
@ -26,36 +30,60 @@ Handler = MyHttpRequestHandler
def compile_and_deploy_contract(): def compile_and_deploy_contract():
password = 'one' password = 'one'
# User # User
user_compile_command = "neo-go contract compile -i User/user.go -c User/user.yml -m User/user.json" 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) subprocess.run(user_compile_command, shell=True, check=False)
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" 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 --force"
subprocess.run(user_deploy_command, shell=True, check=True) proc = subprocess.Popen(user_deploy_command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
result_user = subprocess.check_output(password, shell=True, text=True).stdout[-40:]
print(result_user) user_out_list = []
while True:
line = proc.stdout.readline()
if not line:
break
user_out_list.append(line.rstrip())
user_hash = str(user_out_list[-1]).replace("Contract: ", "")
print(user_hash)
# Post # Post
post_compile_command = "neo-go contract compile -i Post/post_contract.go -c Post/post_contract.yml -m Post/post_contract.json" 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) subprocess.run(post_compile_command, shell=True, check=False)
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" 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 --force"
subprocess.run(post_deploy_command, shell=True, check=True) proc = subprocess.Popen(post_deploy_command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
result_post = subprocess.check_output(password, shell=True, text=True).stdout[-40:]
print(result_post) post_out_list = []
while True:
line = proc.stdout.readline()
if not line:
break
post_out_list.append(line.rstrip())
post_hash = str(post_out_list[-1]).replace("Contract: ", "")
print(post_hash)
# Comment # Comment
comment_compile_command = "neo-go contract compile -i Comment/comment.go -c Comment/comment.yml -m Comment/comment.json" 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) subprocess.run(comment_compile_command, shell=True, check=False)
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" 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 --force"
subprocess.run(comment_deploy_command, shell=True, check=True) proc = subprocess.Popen(comment_deploy_command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
result_comment = subprocess.check_output(password, shell=True, text=True).stdout[-40:]
print(result_comment) comment_out_list = []
while True:
line = proc.stdout.readline()
if not line:
break
comment_out_list.append(line.rstrip())
comment_hash = str(comment_out_list[-1]).replace("Contract: ", "")
print(comment_hash)
if __name__ == "__main__": if __name__ == "__main__":
compile_and_deploy_contract() compile_and_deploy_contract()
with socketserver.TCPServer(("", PORT), Handler) as httpd: # with socketserver.TCPServer(("", PORT), Handler) as httpd:
print("Сервер запущен на порту", PORT) # print("Сервер запущен на порту", PORT)
httpd.serve_forever() # httpd.serve_forever()
httpd.server_close() # httpd.server_close()