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

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -