Can you store files on Replit?

**I’m building a Python/Flask app that generates a docx document, stores it and will then send it to an external API. When I run the app before deployment, it works fine and I can see the new document. However, when I deploy it, the docx files is no longer stored.

Does Replit allow apps to create and store files like this?**

import logging
from flask import Flask, request
import contract
import extractions
import json

# webhook = https://app-fiestas-eqco.replit.app/webhook

# initialize flask app
app = Flask(__name__)


@app.route('/')
def home():
  # Simple route to verify the app is running
  return "Webhook listener is running."


# this is where webhook data is received
@app.route('/webhook', methods=['POST'])
def webhook_listener():
  if request.method == 'POST':
    # check if the incoming request is JSON
    if request.is_json:
      # parse the JSON data from the request
      form_data = json.loads(request.get_json()['rawRequest'])
    else:
      # fallback for form-encoded data
      form_data = json.loads(request.form['rawRequest'])

    # logging.info(f"Received data: {form_data}")
    print(f"Received data: {form_data}")
    # create empty dictionary to store script output
    doc_data = {}
    # get form response data and store in doc_data
    doc_data.update(extractions.client_full_name(form_data))
    doc_data.update(extractions.client_contact_info(form_data))
    doc_data.update(extractions.site_data(form_data))
    doc_data.update(extractions.get_dates(form_data))
    doc_data.update(extractions.atendees(form_data))
    doc_data.update(extractions.responsable(form_data))
    doc_data.update(extractions.marketing(form_data))

    filename = contract.filename(doc_data)

    doc_data.update(extractions.signature(form_data, filename))

    # generate string to name new file and insert data into contract
    contract.contract_filler(doc_data, filename)

    # return an empty response indicating success
    return '', 204

  return "done"


if __name__ == "__main__":
  app.run(host="0.0.0.0", port=8080, debug=True)

Not in deployments, no. Replit is currently working on object storage, though. Some people were offered to join the beta.

5 Likes

This is not the answer I was hoping for, but you saved me countless hours of testing thinking I was doing something wrong.
Thank you.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.