S
S
Shimpanze2020-10-23 11:41:02
Flask
Shimpanze, 2020-10-23 11:41:02

Is it possible to configure Python in such a way that all .py files (as PHP files) are executed in a folder?

Good afternoon!

I'm just starting to learn Python. In connection with this, I have a question.

I installed Flask on the site and I want it to be like in PHP, just create any number of .py files that can be called from the address bar of the browser to execute them. Is there such a possibility in Python?

Well, that is, I create a file in the root of the site blabla.py with the content:

with open('test.txt', 'tw', encoding='utf-8') as f:
    pass


...then I just call it: site.ru/blabla.py and the test.txt file is created in my site root.

Is there such simplicity in Python? Or is it only PHP that has this simplicity?

Thank you!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey Gornostaev, 2020-10-23
@sergey-gornostaev

This simplicity is called "primitive CGI protocol".

D
Dr. Bacon, 2020-10-23
@bacon

This simplicity in fact in slightly more or less complex applications is inconvenient, if you really want to, then it’s easier to write in php.

P
Pasechnik Kuzmich, 2020-10-23
@Hivemaster

It's not about the language, it's about using the framework. In PHP, too, you can’t just throw files into a directory and call them by name if you use Laravel for example.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question