-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup_and_run.sh
183 lines (163 loc) · 4.84 KB
/
setup_and_run.sh
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
179
180
181
182
183
#!/bin/bash
# Name of the application
APP_NAME="NutSearch v0.1"
# Update package list and install Python3 and pip if not installed
echo "Updating package list..."
sudo apt-get update
echo "Installing Python3 and pip..."
sudo apt-get install -y python3 python3-pip
# Install Flask and requests
echo "Installing Flask and requests..."
pip3 install Flask requests
# Create the application directory
APP_DIR="NutSearch"
mkdir -p $APP_DIR
cd $APP_DIR
# Create app.py
cat <<EOL > app.py
from flask import Flask, request, render_template
import requests
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/proxy', methods=['GET', 'POST'])
def proxy():
if request.method == 'POST':
url = request.form['url']
response = requests.get(url)
return response.text
return "Invalid request"
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)
EOL
# Create templates directory
mkdir -p templates
# Create index.html with updated content
cat << 'EOL' > templates/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NutSearch v0.1</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 20px;
}
h1 {
text-align: center;
color: #333;
}
#tabs {
display: flex;
justify-content: center;
margin-bottom: 20px;
}
.tab {
padding: 10px 20px;
border: 1px solid #ccc;
margin-right: 5px;
cursor: pointer;
background-color: #fff;
transition: background-color 0.3s;
}
.tab:hover {
background-color: #e0e0e0;
}
.active-tab {
background-color: #007bff;
color: white;
border-bottom: 1px solid transparent;
}
.tab-content {
display: none;
padding: 20px;
border: 1px solid #ccc;
background-color: white;
border-radius: 5px;
}
.active {
display: block;
}
#proxyResult {
margin-top: 20px;
border: 1px solid #ccc;
padding: 10px;
background-color: #f9f9f9;
border-radius: 5px;
max-height: 400px;
overflow-y: auto;
}
input[type="text"] {
width: calc(100% - 100px);
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
padding: 10px 15px;
border: none;
background-color: #007bff;
color: white;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<h1>NutSearch v0.1</h1>
<div id="tabs">
<div class="tab active-tab" onclick="showTab('proxyTab')">Proxy</div>
<div class="tab" onclick="showTab('erudaTab')">Eruda Console</div>
</div>
<div id="proxyTab" class="tab-content active">
<h2>Web Proxy</h2>
<form id="proxyForm">
<input type="text" name="url" placeholder="Enter URL (e.g., example.com)" required>
<button type="submit">Load</button>
</form>
<div id="proxyResult"></div>
</div>
<div id="erudaTab" class="tab-content">
<h2>Eruda Console</h2>
<script src="https://cdn.jsdelivr.net /npm/eruda/1.5.0/eruda.min.js"></script>
<script>eruda.init();</script>
</div>
<script>
function showTab(tabId) {
document.querySelectorAll('.tab-content').forEach(tab => {
tab.classList.remove('active');
});
document.querySelectorAll('.tab').forEach(tab => {
tab.classList.remove('active-tab');
});
document.getElementById(tabId).classList.add('active');
event.target.classList.add('active-tab');
}
document.getElementById('proxyForm').onsubmit = async function(event) {
event.preventDefault();
const url = event.target.url.value;
const response = await fetch('/proxy', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({ url: url.startsWith('http') ? url : 'http://' + url })
});
const result = await response.text();
document.getElementById('proxyResult').innerHTML = result;
};
</script>
</body>
</html>
EOL
# Run the Flask application
echo "Starting the Flask application..."
python3 app.py