Monday, 13 May 2019

Flask app with ArcGIS, Arcpy does not run

I have a script that gets a table from MSSQL database and then registers it with ArcGIS. It uses several other arcpy methods as well. I tried to combine it with Flask and developed an HTML interface where you can specify tables. The script runs on console perfectly well, however, when running with Flask on http://127.0.0.1:5000/ , the arcpy functions do not run, then the app throws errors.

I am using my local python directory, so I do not have any problem with importing arcpy on flask. So, I am able to use pymssql functions and create a new table, however when it comes to arcpy function, It throws does not exist error, however, the table exists. I feel like there is something wrong with running arcpy with Flask, but any help would be appreciated.

(2) I tried the same thing in Django but I am having the same problem.

Thanks

forms.py

class createGISLayer(FlaskForm):
    tCreateLayer = SubmitField('Create GIS Layer')

DashboardMain()

   try:
        cursor.execute(QueryCreate)
        print ("Table Created.")
        print(self.dbTablePath)
        descTable = arcpy.Describe(self.dbTablePath)

    except arcpy.ExecuteError:
        print(arcpy.GetMessages())

app.py

if formCreate.tCreateLayer.data and formCreate.validate_on_submit():
    if myLayer is not None:
        try:
            print("Create GIS Layer")
            myLayer.dashboardMain()
            flash('GIS Layer created!', 'success')

        except Exception as e:
            print(e.message)
            flash(e.message, 'danger')

index.html

<!-- Create GIS Layer  -->
<div class="content-section">
<form name='idCreateGISLayer' action="" method="POST">
<table style="height: auto; margin-left: auto; margin-right: auto; width: 600px;">
<tbody>
<tr>
    
    <td style="height: 39px; width: 259px">
        <h2 style="text-align: left;"><font size="3"><strong>(2) Create </strong></font></h2>
    </td>
    <td style="text-align: left; height: 39px;">
        <div class="auto-style2">                                                                
            
        </div>
    </td>
 </tr>
 </tbody>
 </table>
 </form>
 </div>

ERROR

Table Created.
F:\Projects\Dashboard\Publish.sde\Publish.dbo.A_WebT1
"F:\Projects\Dashboard\Publish.sde\Publish.dbo.A_WebT1" does not exist

screenshot

Table exists



from Flask app with ArcGIS, Arcpy does not run

No comments:

Post a Comment