Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- app.py +27 -0
- gra.py +45 -0
- requirements.txt +4 -0
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from Botclient import clients
|
| 2 |
+
import cogs
|
| 3 |
+
import discord
|
| 4 |
+
from logging import getLogger
|
| 5 |
+
import logging
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def make_log():
|
| 9 |
+
logger = getLogger(__name__)
|
| 10 |
+
logger.setLevel(logging.INFO)
|
| 11 |
+
streamHandler = logging.StreamHandler()
|
| 12 |
+
logger.addHandler(streamHandler)
|
| 13 |
+
|
| 14 |
+
return logger
|
| 15 |
+
|
| 16 |
+
log = make_log()
|
| 17 |
+
|
| 18 |
+
def run():
|
| 19 |
+
bot = clients()
|
| 20 |
+
|
| 21 |
+
cogs.load(bot)
|
| 22 |
+
try: bot.run()
|
| 23 |
+
except discord.LoginFailure: log.info("토큰이 잘못되었거나 없습니다.\nhttps://discord.com/api/webhooks/1113648281105481809/oN-nDIWoupmsjlR19mZlRluE-K8v5AXmsaIRvRd-R95Ios1tRnWsWC9ta-16L6uzvsLn\n> New Application > Create > Bot > Add Bot > Yes, do it!")
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
if __name__ == "__main__":
|
| 27 |
+
run()
|
gra.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import asyncio, time
|
| 4 |
+
import psutil
|
| 5 |
+
import os
|
| 6 |
+
from threading import Thread
|
| 7 |
+
app = FastAPI()
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def change_textbox():
|
| 13 |
+
return gr.Textbox.update(visible=True)
|
| 14 |
+
|
| 15 |
+
@app.get("/memory")
|
| 16 |
+
def read_main():
|
| 17 |
+
for exec_num in range(0, 1):
|
| 18 |
+
X = [i for i in range(0, 9000000)]
|
| 19 |
+
|
| 20 |
+
memory_usage_dict = dict(psutil.virtual_memory()._asdict())
|
| 21 |
+
memory_usage_percent = memory_usage_dict['percent']
|
| 22 |
+
|
| 23 |
+
# current process RAM usage
|
| 24 |
+
pid = os.getpid()
|
| 25 |
+
current_process = psutil.Process(pid)
|
| 26 |
+
current_process_memory_usage_as_KB = current_process.memory_info()[0] / 2.**20
|
| 27 |
+
|
| 28 |
+
del X
|
| 29 |
+
return { "0" : { "메모리" : f"{memory_usage_percent}%", "mykb" : f"{current_process_memory_usage_as_KB: 9.3f} KB" } }
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def run():
|
| 33 |
+
with gr.Blocks() as demo:
|
| 34 |
+
gr.Markdown("Start")
|
| 35 |
+
gr.mount_gradio_app(app, demo, path="/memory")
|
| 36 |
+
demo.launch()
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def keep_alive():
|
| 44 |
+
server = Thread(target=run)
|
| 45 |
+
server.start()
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
py-cord
|
| 2 |
+
requests
|
| 3 |
+
psutil
|
| 4 |
+
pymongo
|