Update main.py
Browse files
main.py
CHANGED
|
@@ -3,10 +3,10 @@ from fastapi import FastAPI, Request, Body, Response
|
|
| 3 |
from fastapi.middleware.cors import CORSMiddleware
|
| 4 |
from requests import get
|
| 5 |
# from uvicorn import run
|
| 6 |
-
import docker
|
| 7 |
|
| 8 |
|
| 9 |
-
client = docker.from_env()
|
| 10 |
|
| 11 |
|
| 12 |
app = FastAPI(
|
|
@@ -41,33 +41,33 @@ def query_ip():
|
|
| 41 |
except Exception:
|
| 42 |
return 'timeout'
|
| 43 |
|
| 44 |
-
def tasks():
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
# l = '-----'.join([str(i) for i in client.images.list()])
|
| 50 |
-
# if not "traffmonetizer/cli:latest" in l:
|
| 51 |
-
# client.images.pull('traffmonetizer/cli:latest')
|
| 52 |
-
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
|
| 62 |
@app.get('/')
|
| 63 |
def index():
|
| 64 |
ip = query_ip()
|
| 65 |
return {'ip': ip}
|
| 66 |
|
| 67 |
-
@app.get('/dockers')
|
| 68 |
-
def dockers():
|
| 69 |
-
|
| 70 |
-
|
| 71 |
|
| 72 |
# if __name__ == '__main__':
|
| 73 |
# run(app='main:app', host= '0.0.0.0', port=1080, reload=True)
|
|
|
|
| 3 |
from fastapi.middleware.cors import CORSMiddleware
|
| 4 |
from requests import get
|
| 5 |
# from uvicorn import run
|
| 6 |
+
# import docker
|
| 7 |
|
| 8 |
|
| 9 |
+
# client = docker.from_env()
|
| 10 |
|
| 11 |
|
| 12 |
app = FastAPI(
|
|
|
|
| 41 |
except Exception:
|
| 42 |
return 'timeout'
|
| 43 |
|
| 44 |
+
# def tasks():
|
| 45 |
+
# ip = query_ip()
|
| 46 |
+
# for i in client.containers.list():
|
| 47 |
+
# print(i.stop())
|
| 48 |
+
# print(i.remove())
|
| 49 |
+
# # l = '-----'.join([str(i) for i in client.images.list()])
|
| 50 |
+
# # if not "traffmonetizer/cli:latest" in l:
|
| 51 |
+
# # client.images.pull('traffmonetizer/cli:latest')
|
| 52 |
+
# # res = client.containers.run("traffmonetizer/cli", "start accept --token jniTVESOzawsUvbUbprTL++Flag1g+CWwryIpJgGIK8= --device-name docker-1")
|
| 53 |
|
| 54 |
+
# res = client.containers.run(
|
| 55 |
+
# image="traffmonetizer/cli:latest",
|
| 56 |
+
# command=f"-d --name tm start accept --token jniTVESOzawsUvbUbprTL++Flag1g+CWwryIpJgGIK8= --device-name {ip}",
|
| 57 |
+
# # volumes=["somevolume:/insidecontainer"],
|
| 58 |
+
# detach=True
|
| 59 |
+
# )
|
| 60 |
+
# return f'{str(res)}-{ip}'
|
| 61 |
|
| 62 |
@app.get('/')
|
| 63 |
def index():
|
| 64 |
ip = query_ip()
|
| 65 |
return {'ip': ip}
|
| 66 |
|
| 67 |
+
# @app.get('/dockers')
|
| 68 |
+
# def dockers():
|
| 69 |
+
# result = tasks()
|
| 70 |
+
# return Response(content=result,status_code=200, media_type='application/text; charset=utf-8')
|
| 71 |
|
| 72 |
# if __name__ == '__main__':
|
| 73 |
# run(app='main:app', host= '0.0.0.0', port=1080, reload=True)
|