python - Paths on DigitalOcean with Flask -
i have flask application on digitalocean creates file(shapefile)
, , later on reads again. how write paths of file, make sure can read later again?
use paths relative application's root. in flask application object ( app
) has .root_path
attribute can use create absolute paths files. like:
with open(os.path.join(app.root_path, 'shapefiles', file_name), 'w') f: f.write(....)
and later reverse
with open(os.path.join(app.root_path, 'shapefiles', file_name), 'r') f: data = f.read(....)
Comments
Post a Comment