-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
64 lines (54 loc) · 1.44 KB
/
main.py
File metadata and controls
64 lines (54 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from fastapi import FastAPI, Form
from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
from libs.system_info import get_system_info
from libs.port_utils import runPort
from libs.wifi_utils import connect_to_network, scan_networks
from libs.port_list import portList
from libs.port_check import portCheck
from libs.search_files import searchFile
app = FastAPI()
app.mount("/static", StaticFiles(directory="static"), name="static")
@app.get("/")
def root():
return FileResponse("static/index.html")
@app.get("/api/system")
async def systemInfo():
info = get_system_info()
return info
@app.post("/api/ports/run-port")
async def openPort(
port: str = Form(...),
loc: str = Form(...)
):
server = runPort(port, loc)
return server
@app.get("/api/wifi/scan")
async def scanWifi():
networks = scan_networks()
return networks
@app.post("/api/wifi/connect")
async def connectWifi(
ssid: str = Form(...),
pswd: str = Form(...)
):
connect = connect_to_network(ssid, pswd)
return connect
@app.get("/api/ports/list")
async def apiPortList():
ports = portList()
return ports
@app.post("/api/ports/check")
async def apiPortCheck(
a: str = Form(...),
p: str = Form(...)
):
result = portCheck(a, p)
return result
@app.post("/api/files/search")
async def apiSearchFiles(
d: str = Form(...),
n: str = Form(...)
):
files = searchFile(f"{d}\\", n)
return files