您好,老师:
我是之前在微信群里向您请教问题的学员,一下是我的代码和问题:
server:
#coding=utf-8
from flask import Flask
import ConfigParser
import json
from flask import request
import arcpy
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
@app.route("/json_Analysis",methods = ['GET', 'POST'])
def json_Analysis():
if request.method == 'POST':
data = request.get_data()
json_data = json.loads(data.decode("utf-8"))
return json.dumps(json_data)
@app.route("/exist_Analysis",methods = ['GET', 'POST'])
def exist_Analysis():
if request.method == 'POST':
data = request.get_data()
json_data = json.loads(data.decode("utf-8"))
arcpy.env.workspace = r'C:\Users\Administrator\AppData\Roaming\ESRI\Desktop10.6\ArcCatalog\Connection to PDBORCL.sde'
fcs = arcpy.ListFeatureClasses()
s = len(fcs)
for fc in fcs:
if fc.title().upper() == 'SDE.TEST1':
val =2
return json.dumps(json_data)
client:
#coding=utf-8
import requests
headers = {"Content-Type": "application/json; charset=UTF-8"}
url_Json = 'http://127.0.0.1:5000/json_Analysis'
url_Exist = 'http://127.0.0.1:5000/exist_Analysis'
entities = [{"name1": "bad", "filters": {"key1": "value1","key2": "value2"}},
{"name2": "bad", "filters": {"key1": "value1","key2": "value2"}},
{"name3": "bad", "filters": {"key1": "value1","key2": "value2"}},
{"name4": "bad", "filters": {"key1": "value1","key2": "value2"}},]
def json_Analysis():
json_Info = requests.post(url_Json,json = entities,headers = headers)
print json_Info.status_code
print json_Info.url
print json_Info.text
def exist_Analysis():
exist_Info = requests.post(url_Exist,json = entities,headers = headers)
print exist_Info.status_code
print exist_Info.url
print exist_Info.text
exist_Analysis()
json_data = json_Analysis()
目录:

错误信息:
500
http://127.0.0.1:5000/exist_Analysis
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>
个人思考:
arcpy是用来处理空间数据的,由ESRI公司发布。
fcs = arcpy.ListFeatureClasses()返回的是目标库里的空间数据集,这一步还没报错,但当进一步检索fcs的length以及fcs里某个目标要素时就会出问题。
arcpy不是通过pip导入的,是第三方库,我在想引用这样的库是否需要特别处理还是不能这么操作?还得麻烦老师帮忙解答下,先谢过了