-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
48 lines (38 loc) · 953 Bytes
/
server.py
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
#!/bin/python3
from flask import Flask, request
import flask
import requests
import logging
logging.getLogger("werkzeug").disabled = True
app = Flask(__name__)
@app.route('/', methods = ['POST', 'GET'])
def mainFunc():
if request.method == 'GET':
url = request.args.get('url')
else:
url = request.data
req = requests.get(url)
print(url)
# print(req.status_code)
text_data = req.text
if req.status_code != 404:
json_data = req.json()
print(json_data["title"])
print(json_data["url"])
else:
print(req.status_code)
text_data = ""
resp = flask.make_response(text_data)
resp.headers["Access-Control-Allow-Origin"] = "*"
return resp
# @app.route('/image', methods = ['POST', 'GET'])
# def image():
# x = requests.get(request.data)
# textt = x.text
#
# resp = flask.make_response(textt)
# resp.headers["Access-Control-Allow-Origin"] = "*"
#
# return resp
if __name__ == '__main__':
app.run(debug=True, port=5000)