Making a Python Framework

Question:
So I am trying to make a framework for Python to easily make HTML websites comfortably using Python instead of using HTML (kind of like Flask), I’m running into issues where the Repl doesn’t start a Webview server. (Note: I am making this with a blank Repl and not Python or anything).

Repl link:
https://replit.com/@SalladShooter/Vial#app.py

# app.py

from werkzeug.wrappers import Request, Response
from werkzeug.serving import run_simple

class MyApp:
    def __call__(self, environ, start_response):
        request = Request(environ)
        response = Response('Hello, World!')
        return response(environ, start_response)

if __name__ == '__main__':
    app = MyApp()
    run_simple('localhost',  5000, app)

.replit

run = "python3 app.py"

[nix]
channel = "stable-23_11"
1 Like

Change ’localhost’ to ‘0.0.0.0’.

1 Like

@RedCoder thanks, this is what I have →

# app.py

from werkzeug.wrappers import Request, Response
from werkzeug.serving import run_simple

class MyApp:
    def __call__(self, environ, start_response):
        request = Request(environ)
        response = Response('Hello, World!')
        return response(environ, start_response)

if __name__ == '__main__':
    app = MyApp()
    run_simple('localhost', 0.0.0.0, app)

But it still gives me an error of ‘sh: line 1: python3: command not found’.

Well, that’s because it’s a blank Repl. Why not use a Python Repl?

Make the deps array in replit.nix empty, and paste this into the .replit file.

entrypoint = "app.py"
modules = ["python-3.10:v18-20230807-322e88b"]
hidden = [".pythonlibs"]

[nix]
channel = "stable-23_05"

[unitTest]
language = "python3"

[deployment]
run = ["python3", "main.py"]
deploymentTarget = "cloudrun"

Also, put 0.0.0.0 in quotation marks.

3 Likes

Like Qwerty said, you should do that, but I meant change the line to:

run_simple('0.0.0.0', 5000, app)
2 Likes

@RedCoder @QwertyQwerty88 Thank you guys so much it worked!

23 posts were split to a new topic: Syntax/Undefined error in my framework

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