Upload 4 files
Browse files- DockerFile +10 -9
- app.py +44 -54
- templates/index.html +1 -1
DockerFile
CHANGED
@@ -1,9 +1,10 @@
|
|
1 |
-
FROM python:3.9
|
2 |
-
|
3 |
-
WORKDIR /
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
1 |
+
FROM python:3.9
|
2 |
+
|
3 |
+
WORKDIR /python-docker
|
4 |
+
|
5 |
+
COPY requirements.txt requirements.txt
|
6 |
+
RUN pip3 install -r requirements.txt
|
7 |
+
|
8 |
+
COPY . .
|
9 |
+
|
10 |
+
CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]
|
app.py
CHANGED
@@ -1,54 +1,44 @@
|
|
1 |
-
from
|
2 |
-
from
|
3 |
-
import requests
|
4 |
-
|
5 |
-
app =
|
6 |
-
|
7 |
-
|
8 |
-
app.
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
)
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
response
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
return response.text.strip() # Return the response text from the external system
|
47 |
-
|
48 |
-
except requests.exceptions.RequestException as e:
|
49 |
-
print(f"Error: {e}")
|
50 |
-
return '0' # Return '0' or handle error as per your application's requirements
|
51 |
-
|
52 |
-
if __name__ == '__main__':
|
53 |
-
import uvicorn
|
54 |
-
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
1 |
+
from flask import Flask, render_template, request, jsonify
|
2 |
+
from flask_cors import CORS
|
3 |
+
import requests
|
4 |
+
|
5 |
+
app = Flask(__name__)
|
6 |
+
CORS(app)
|
7 |
+
|
8 |
+
@app.route('/')
|
9 |
+
def index():
|
10 |
+
return render_template('index.html')
|
11 |
+
|
12 |
+
@app.route('/login', methods=["POST"])
|
13 |
+
def loginChat():
|
14 |
+
username = request.form.get('username')
|
15 |
+
password = request.form.get('password')
|
16 |
+
|
17 |
+
# Call send_request function to handle the HTTP POST request to external system
|
18 |
+
response = send_request(password, username)
|
19 |
+
|
20 |
+
# Process the response and return appropriate JSON response
|
21 |
+
if response == '1':
|
22 |
+
return jsonify({'response': 1, 'message': 'Login successful'})
|
23 |
+
elif response == '2':
|
24 |
+
return jsonify({'response': 2, 'message': 'Invalid username or password'})
|
25 |
+
elif response == '3':
|
26 |
+
return jsonify({'response': 3, 'message': 'Special action required (e.g., page reload)'})
|
27 |
+
else:
|
28 |
+
return jsonify({'response': 0, 'message': 'Unknown response from external system'})
|
29 |
+
|
30 |
+
def send_request(password, username):
|
31 |
+
try:
|
32 |
+
response = requests.post('https://girlschat.org/chat/system/encoded/login.php', data={
|
33 |
+
'password': password,
|
34 |
+
'username': username
|
35 |
+
})
|
36 |
+
|
37 |
+
return response.text.strip() # Return the response text from the external system
|
38 |
+
|
39 |
+
except requests.exceptions.RequestException as e:
|
40 |
+
print(f"Error: {e}")
|
41 |
+
return '0' # Return '0' or handle error as per your application's requirements
|
42 |
+
|
43 |
+
if __name__ == '__main__':
|
44 |
+
app.run(host='0.0.0.0', port=8000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
templates/index.html
CHANGED
@@ -51,7 +51,7 @@ sendLogin = function(){
|
|
51 |
else {
|
52 |
if(waitReply == 0){
|
53 |
waitReply = 1;
|
54 |
-
$.post('/
|
55 |
password: upass,
|
56 |
username: uuser
|
57 |
}, function(response) {
|
|
|
51 |
else {
|
52 |
if(waitReply == 0){
|
53 |
waitReply = 1;
|
54 |
+
$.post('/login', {
|
55 |
password: upass,
|
56 |
username: uuser
|
57 |
}, function(response) {
|