-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
56 lines (41 loc) · 1.28 KB
/
main.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
49
50
51
52
53
54
55
56
import wave
import flask
from flask import Flask, request, redirect, render_template
from flask_cors import CORS
import requests
from bs4 import BeautifulSoup
headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': '*',
'Access-Control-Allow-Headers': 'Content-Type',
'Access-Control-Max-Age': '3600',
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0'
}
app = Flask(__name__)
CORS(app)
@app.route("/")
def index():
return render_template('home.html')
@app.route("/clients")
def mod():
return render_template('clients.html')
@app.route("/more")
def about():
return render_template('more.html')
@app.route("/predict", methods=["POST"])
def pred():
file = 0
if request.method == "POST":
file = request.files['file'].read()
req = requests.get("https://anotepad.com/note/read/2k9nbd2g", headers)
soup = BeautifulSoup(req.content)
url = soup.select_one('.plaintext').get_text()
files = {'file': file}
#url = "http://127.0.0.1:5500/predict"
r = requests.post(url, data=file)
print(r.text)
return {"data": str(r.text)}
if __name__ == '__main__':
app.config["TEMPLATES_AUTO_RELOAD"] = True
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
app.run()