the code on the server is as follows
from __future__ import unicode_literals
from flask_restful import Api
from flask import Flask,request
import time
import datetime
-sharp-sharp-sharp-sharp-sharp-sharp-sharp-sharp-sharpproduct==========
import json
-sharp-sharp-sharp-sharp-sharp11.46
import TextDropRepeat as tdr
import pymongo
import numpy as np
from numpy import array
app = Flask(__name__)
app.debug = True
app.config.update(RESTFUL_JSON=dict(ensure_ascii=False))
api = Api(app)
TODOS = {
"conhashGroup": {"task": []},
"publishtime": {"task":[]},
"conhashGroupA": {"task": []},
"conhashGroupB": {"task": []},
"conhashGroupC": {"task": []},
"conhashGroupD": {"task": []},
}
from flask_restful import reqparse
parser = reqparse.RequestParser()
parser.add_argument("task")
@app.route("/")
def hello_world():
return "hello world"
@app.route("/drop_TextRepeat/", methods=["POST"])
def add_task():
print (TODOS)
nowTime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
pastTime = (datetime.datetime.now()-datetime.timedelta(days=5)).strftime("%Y-%m-%d %H:%M:%S")
time_start=time.time()
print ("")
-sharp-sharp-sharp-sharp
try:
data1 = request.form.get("data")
print (1)
except:
data1 = request.data
print (2)
-sharpprint (data1)
print ("")
for line in data1.split("\n"):
if "DRETITLE" in line:
title = line.split("-sharpDRETITLE")[1].strip()
if "PUBLISHDATE" in line:
publishdate = line.replace("=","").replace(""","").split("PUBLISHDATE")[1].strip().replace(""","")
print (publishdate)
print (title)
-sharp-sharp-sharp64hash
ConHash = tdr.simhash(title)
-sharp-sharp-sharp-sharp4*16hash
ConHashA = str(ConHash)[0:16]
ConHashB = str(ConHash)[16:32]
ConHashC = str(ConHash)[32:48]
ConHashD = str(ConHash)[48:]
if ConHashA in TODOS["conhashGroupA"]["task"]:
print (3)
TODOS["conhashGroup"]["task"].append(ConHash)
TODOS["publishtime"]["task"].append(publishdate)
TODOS["conhashGroupA"]["task"].append(ConHashA)
TODOS["conhashGroupB"]["task"].append(ConHashB)
TODOS["conhashGroupC"]["task"].append(ConHashC)
TODOS["conhashGroupD"]["task"].append(ConHashD)
index = np.where((pastTime<=array(TODOS["publishtime"]["task"])) & (array(TODOS["publishtime"]["task"])<nowTime ))[0].tolist()
TODOS["publishtime"]["task"] = np.array(TODOS["publishtime"]["task"])[index].tolist()
TODOS["conhashGroup"]["task"] = np.array(TODOS["conhashGroup"]["task"])[index].tolist()
TODOS["conhashGroupA"]["task"] = np.array(TODOS["conhashGroupA"]["task"])[index].tolist()
TODOS["conhashGroupB"]["task"] = np.array(TODOS["conhashGroupB"]["task"])[index].tolist()
TODOS["conhashGroupC"]["task"] = np.array(TODOS["conhashGroupC"]["task"])[index].tolist()
TODOS["conhashGroupD"]["task"] = np.array(TODOS["conhashGroupD"]["task"])[index].tolist()
time_end=time.time()
print ("totally cost",time_end-time_start)
return "ok"
if __name__ == "__main__":
app.run(host = "0.0.0.0")
uwsgi configuration file is as follows
[uwsgi]
socket=/tmp/uwsgi.sock
mount=/myapp=/home/nlp/pyfoot/TD/DropText.py
manage-script-name=true
master=true
processes=4
threads=2
stats=127.0.0.1:9191
callable=app
daemonize = /home/nlp/pyfoot/TD/DropText.log
nginx is configured as follows
-sharp For more information on configuration, see:
-sharp * Official English Documentation: http://nginx.org/en/docs/
-sharp * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
-sharp Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main "$remote_addr - $remote_user [$time_local] "$request" "
"$status $body_bytes_sent "$http_referer" "
""$http_user_agent" "$http_x_forwarded_for"";
server {
listen 8000;
access_log /home/nlp/pyfoot/TD/DR.log main;
server_name 172.22.11.46;
location /myapp {
root /myapp;
include uwsgi_params;
-sharpuwsgi_param SCRIPT_NAME/myapp;
uwsgi_pass unix:/tmp/uwsgi.sock;
}
}
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
-sharp Load modular configuration files from the /etc/nginx/conf.d directory.
-sharp See http://nginx.org/en/docs/ngx_core_module.html-sharpinclude
-sharp for more information.
include /etc/nginx/conf.d/*.conf;
}
when I visit the server from my local computer browser, helloworld
pypost
is displayed normally
the return value of python is as follows
r.text
Out[29]: "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n<title>404 Not Found</title>\n<h1>Not Found</h1>\nThe requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
\n"
I would like to ask the boss, what is the situation? the browser can be accessed successfully, which means there is no problem with the configuration, but if you change the post interface, you will report an error. I have not understood it all the time, and I also ask the boss to answer the questions
.