-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.html
178 lines (161 loc) · 5.99 KB
/
api.html
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WebShell API Documentation</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
body {
background-color: #2e2e2e;
color: #f0f0f0;
}
.container {
margin-top: 30px;
}
.section-title {
color: #f0f0f0; /* Changed header text color */
border-bottom: 2px solid #f0f0f0; /* Matching border color */
padding-bottom: 10px;
}
pre code {
color: #9b59b6; /* Purple color for code blocks */
}
code {
color: #9b59b6; /* Purple color for inline code */
}
.btn-primary {
background-color: #9b59b6;
border: none;
}
.btn-primary:hover {
background-color: #8e44ad;
}
a {
color: #9b59b6;
}
a:hover {
color: #fff;
}
nav {
background-color: #333;
}
nav a {
color: #f0f0f0;
}
nav a:hover {
color: #9b59b6;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark">
<a class="navbar-brand" href="#">WebShell</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="index.html">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="api.html">API</a>
</li>
<li class="nav-item">
<a class="nav-link" href="features.html">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="terminal.html">Getting Started</a>
</li>
</ul>
</div>
</nav>
<header class="text-center text-white py-5">
<div class="container">
<h1 class="display-4">WebShell API Documentation</h1>
<p class="lead">Learn how to use the WebShell API to execute commands programmatically.</p>
</div>
</header>
<div class="container">
<section>
<h2 class="section-title">Overview</h2>
<p>The WebShell API allows you to execute Fedora commands programmatically through HTTP POST requests. This API is designed to interact with a web-based Fedora terminal, enabling you to run commands and retrieve their output in a structured format.</p>
</section>
<section>
<h2 class="section-title">Base URL</h2>
<p><code>https://web-terminal-eight.vercel.app</code></p>
</section>
<section>
<h2 class="section-title">Endpoints</h2>
<h3>1. Run Command</h3>
<p><strong>Endpoint:</strong> <code>/run</code></p>
<p><strong>Method:</strong> POST</p>
<p><strong>Content-Type:</strong> application/json</p>
<h4>Description</h4>
<p>This endpoint allows you to execute a Fedora command in the WebShell terminal. The command is provided as a JSON payload, and the API returns the output of the command.</p>
<h4>Request</h4>
<p><strong>URL:</strong></p>
<pre><code>https://web-terminal-eight.vercel.app/run</code></pre>
<p><strong>Headers:</strong></p>
<pre><code>Content-Type: application/json</code></pre>
<p><strong>Body:</strong></p>
<pre><code>{
"command": "your-command-here"
}</code></pre>
<p>Replace <code>"your-command-here"</code> with the actual command you wish to run.</p>
<h4>Example Request</h4>
<p>To list files and directories in the current directory, you would use the following <code>curl</code> command:</p>
<pre><code>curl -X POST https://web-terminal-eight.vercel.app/run \
-H "Content-Type: application/json" \
-d '{"command": "ls -l"}'</code></pre>
<h4>Response</h4>
<p>The response will be a JSON object with the following structure:</p>
<pre><code>{
"stdout": "command output here",
"stderr": "error output here",
"exitCode": exit_code
}</code></pre>
<ul>
<li><code>stdout</code>: The standard output of the command.</li>
<li><code>stderr</code>: The standard error output of the command (if any).</li>
<li><code>exitCode</code>: The exit code of the command.</li>
</ul>
<h4>Example Response</h4>
<p>For the command <code>ls -l</code>, you might receive:</p>
<pre><code>{
"stdout": "total 2\ndrwxr-xr-x 67 root root 1187 Jul 27 00:36 node_modules\n-rwxr-xr-x 1 root root 303 Oct 20 2018 package.json\n-rwxr-xr-x 1 root root 753 Oct 20 2018 server.js\n"
}</code></pre>
<h4>Error Handling</h4>
<ul>
<li><strong>400 Bad Request:</strong> The request was invalid. Ensure the JSON payload is properly formatted.</li>
<li><strong>500 Internal Server Error:</strong> An error occurred while processing the command. Check the server logs for details.</li>
</ul>
</section>
<section>
<h2 class="section-title">Examples</h2>
<h4>Example 1: Listing Files</h4>
<pre><code>curl -X POST https://web-terminal-eight.vercel.app/run \
-H "Content-Type: application/json" \
-d '{"command": "ls -l"}'</code></pre>
<h4>Example 2: Viewing Disk Usage</h4>
<pre><code>curl -X POST https://web-terminal-eight.vercel.app/run \
-H "Content-Type: application/json" \
-d '{"command": "df -h"}'</code></pre>
</section>
<section>
<h2 class="section-title">Notes</h2>
<ul>
<li>Ensure that your command does not require interactive input, as the API does not support interactive sessions.</li>
<li>Use the API responsibly to avoid overloading the server with frequent or complex commands.</li>
</ul>
</section>
</div>
<footer class="text-center py-4">
<p>© 2024 WebShell. All rights reserved.</p>
</footer>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>