Skip to content

Commit 0dc2bf8

Browse files
committed
feat: add axios to try api
1 parent 130a5c6 commit 0dc2bf8

File tree

5 files changed

+221
-4
lines changed

5 files changed

+221
-4
lines changed

Diff for: .gitignore

+140
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,143 @@ npm-debug.log.*
4848
*.css.d.ts
4949
*.sass.d.ts
5050
*.scss.d.ts
51+
52+
53+
# Byte-compiled / optimized / DLL files
54+
__pycache__/
55+
*.py[cod]
56+
*$py.class
57+
58+
# C extensions
59+
*.so
60+
61+
# Distribution / packaging
62+
.Python
63+
build/
64+
develop-eggs/
65+
dist/
66+
downloads/
67+
eggs/
68+
.eggs/
69+
lib/
70+
lib64/
71+
parts/
72+
sdist/
73+
var/
74+
wheels/
75+
share/python-wheels/
76+
*.egg-info/
77+
.installed.cfg
78+
*.egg
79+
MANIFEST
80+
81+
# PyInstaller
82+
# Usually these files are written by a python script from a template
83+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
84+
*.manifest
85+
*.spec
86+
87+
# Installer logs
88+
pip-log.txt
89+
pip-delete-this-directory.txt
90+
91+
# Unit test / coverage reports
92+
htmlcov/
93+
.tox/
94+
.nox/
95+
.coverage
96+
.coverage.*
97+
.cache
98+
nosetests.xml
99+
coverage.xml
100+
*.cover
101+
*.py,cover
102+
.hypothesis/
103+
.pytest_cache/
104+
cover/
105+
106+
# Translations
107+
*.mo
108+
*.pot
109+
110+
# Django stuff:
111+
*.log
112+
local_settings.py
113+
db.sqlite3
114+
db.sqlite3-journal
115+
116+
# Flask stuff:
117+
instance/
118+
.webassets-cache
119+
120+
# Scrapy stuff:
121+
.scrapy
122+
123+
# Sphinx documentation
124+
docs/_build/
125+
126+
# PyBuilder
127+
.pybuilder/
128+
target/
129+
130+
# Jupyter Notebook
131+
.ipynb_checkpoints
132+
133+
# IPython
134+
profile_default/
135+
ipython_config.py
136+
137+
# pyenv
138+
# For a library or package, you might want to ignore these files since the code is
139+
# intended to run in multiple environments; otherwise, check them in:
140+
# .python-version
141+
142+
# pipenv
143+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
144+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
145+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
146+
# install all needed dependencies.
147+
#Pipfile.lock
148+
149+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
150+
__pypackages__/
151+
152+
# Celery stuff
153+
celerybeat-schedule
154+
celerybeat.pid
155+
156+
# SageMath parsed files
157+
*.sage.py
158+
159+
# Environments
160+
.env
161+
.venv
162+
env/
163+
venv/
164+
ENV/
165+
env.bak/
166+
venv.bak/
167+
168+
# Spyder project settings
169+
.spyderproject
170+
.spyproject
171+
172+
# Rope project settings
173+
.ropeproject
174+
175+
# mkdocs documentation
176+
/site
177+
178+
# mypy
179+
.mypy_cache/
180+
.dmypy.json
181+
dmypy.json
182+
183+
# Pyre type checker
184+
.pyre/
185+
186+
# pytype static type analyzer
187+
.pytype/
188+
189+
# Cython debug symbols
190+
cython_debug/

Diff for: app/components/Home.tsx

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
1-
import React from 'react';
1+
import React, { useEffect, useState } from 'react';
22
import { Link } from 'react-router-dom';
3+
import axios from 'axios';
34
import routes from '../constants/routes.json';
45
import styles from './Home.css';
56

67
export default function Home(): JSX.Element {
8+
const [state, setState] = useState<string>('Hi');
9+
10+
useEffect(() => {
11+
// axios
12+
// .get('http://localhost:5000')
13+
// .then((res) => setState(res.data))
14+
// .catch(console.log);
15+
}, []);
16+
717
return (
818
<div className={styles.container} data-tid="container">
9-
<h2>Home</h2>
10-
<Link to={routes.COUNTER}>to Counter</Link>
19+
<h2>{state}</h2>
20+
<Link to={routes.COUNTER}>FTG</Link>
1121
</div>
1222
);
1323
}

Diff for: app/main.dev.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import path from 'path';
1414
import { app, BrowserWindow } from 'electron';
1515
import { autoUpdater } from 'electron-updater';
1616
import log from 'electron-log';
17+
// import { execFile } from 'child_process';
1718
import MenuBuilder from './menu';
1819

1920
export default class AppUpdater {
@@ -26,6 +27,9 @@ export default class AppUpdater {
2627

2728
let mainWindow: BrowserWindow | null = null;
2829

30+
// const executablePath = 'resources/app.exe';
31+
// const backend = execFile(executablePath);
32+
2933
if (process.env.NODE_ENV === 'production') {
3034
const sourceMapSupport = require('source-map-support');
3135
sourceMapSupport.install();
@@ -115,7 +119,6 @@ const createWindow = async () => {
115119
/**
116120
* Add event listeners...
117121
*/
118-
119122
app.on('window-all-closed', () => {
120123
// Respect the OSX convention of having the application in memory even
121124
// after all windows have been closed

Diff for: backend/app.py

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
from flask import Flask
2+
from datetime import datetime
3+
import docker
4+
5+
app = Flask(__name__)
6+
7+
import os
8+
9+
10+
@app.route('/')
11+
def hello_world():
12+
return 'Hello World!'
13+
14+
15+
@app.route('/docker/info')
16+
def docker_info():
17+
client = docker.from_env()
18+
info = client.info()
19+
print(info)
20+
return 'ok'
21+
22+
23+
@app.route('/docker/containers')
24+
def docker_containers():
25+
client = docker.from_env()
26+
for container in client.containers.list():
27+
print(container.name)
28+
return 'ok'
29+
30+
31+
@app.route('/docker/influxdb/version')
32+
def docker_influxdb_version():
33+
client = docker.from_env()
34+
for container in client.containers.list():
35+
if container.name == "influxdb":
36+
exec_log = container.exec_run("influx -version")
37+
if exec_log[0] == 0:
38+
return exec_log[1]
39+
return 'mad'
40+
41+
42+
@app.route('/docker/influxdb/backup')
43+
def docker_influxdb_backup():
44+
client = docker.from_env()
45+
for container in client.containers.list():
46+
if container.name == "influxdb":
47+
now = datetime.now().strftime("%d-%m-%Y_%H-%M-%S")
48+
exec_log = container.exec_run(f"influxd backup -portable /backup/{now}_akatech_influx_backup")
49+
if exec_log[0] == 0:
50+
# Parent Directory path
51+
parent_dir = 'C:\influxdbbackup'
52+
53+
if not os.path.exists(parent_dir):
54+
os.makedirs(parent_dir)
55+
56+
os.system(f"docker cp influxdb:/backup/{now}_akatech_influx_backup {parent_dir}")
57+
# client.exec_run(f"docker cp influxdb:/backup/{now}_akatech_influx_backup C:\influxbackup")
58+
return exec_log[1]
59+
return 'mad'
60+
61+
62+
if __name__ == '__main__':
63+
app.run()

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@
278278
"@fortawesome/fontawesome-free": "^5.15.0",
279279
"@hot-loader/react-dom": "^16.13.0",
280280
"@reduxjs/toolkit": "^1.4.0",
281+
"axios": "^0.21.0",
281282
"connected-react-router": "^6.6.1",
282283
"electron-debug": "^3.1.0",
283284
"electron-log": "^4.2.4",

0 commit comments

Comments
 (0)