A
A
a2020-05-20 03:09:24
Python
a, 2020-05-20 03:09:24

How to allow a file to be viewed?

I want to add my heroku project to wakemydyno.com and need to create a wakemydyno.txt file with any content.
I tried like this:

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello, World!'

@app.route('/wakemydyno.txt')
def wakemydyno():
  return 'For wakemydyno.com'


But when adding a project, they say that the file was not found.
How can I allow this file to be viewed at the root, since flask does not allow viewing it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2020-05-20
@MZOK

from flask import Response


@app.route("/wakemydyno.txt")
def get_text():
    content = 'Lorem ipsum dolor sit amet'

    return Response(content, mimetype="text/plain")

5ec506559b46d300496661.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question