How to use file operations using python in render?

from flask import Flask
app = Flask(__name__)
@app.route('/')
def test():
    with open("test.txt", 'w') as f:
        f.write("test")
    with open("test.txt", 'r') as f:
        c = f.readlines()
    return c

i want to do this but its not working, Internal Server Error

Hi there,

Your python code for reading/writing seems fine. I’d suggest forking https://render.com/docs/deploy-flask then copying your code into the hello_world function to see that it works.

If your running into other errors, it would be helpful to include those logs here.

Regards,

Matt

Okay i am so sorry i woke up at like 7 am and then checked this and mis read the whole thing, i did this and it gave me the same Internal Server Error
Sep 22 12:37:07 AM TypeError: call() missing 1 required positional argument: ‘start_response’
Sep 22 12:37:07 AM INFO: 156.211.157.64:0 - “GET /favicon.ico HTTP/1.1” 500 Internal Server Error

Hi there,

Do you have a public repo based on our flask quick start you can share?

Regards,

Matt

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