会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132358个问题
Python 全系列/第一阶段:Python入门/函数和内存分析 4411楼
Python 全系列/第一阶段:Python入门/函数和内存分析 4418楼
Python 全系列/第一阶段:Python入门/控制语句 4419楼
Python 全系列/第一阶段:Python入门/函数和内存分析 4422楼

您好,老师:

      我是之前在微信群里向您请教问题的学员,一下是我的代码和问题:

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()

目录:

image.png

错误信息:

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导入的,是第三方库,我在想引用这样的库是否需要特别处理还是不能这么操作?还得麻烦老师帮忙解答下,先谢过了

Python 全系列/第一阶段:Python入门/Python入门(动画版) 4424楼
Python 全系列/第一阶段:Python入门/控制语句 4425楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637