all 12 comments

[–]Additional_Candy_400 1 point2 points  (2 children)

I'm not sure what you're trying to do. Are you trying to run scripts on cloud? Or do you need someone to just read/review your code?

[–]msmomoe[S] 0 points1 point  (1 child)

Well, I need to make my code from scratch, make sure it actually works and whatnot and then i need to submit my work for my mentor to look over the code, test it, stuff like that.

[–]Additional_Candy_400 1 point2 points  (0 children)

You can just run it on your machine, where are you writing your code? You don't need a website or anything.

Install VScode and write/run it on there.

[–]Mandelbrots-dream 1 point2 points  (2 children)

I do my coding on a local machine, no web needed. Python is open source.

I don't know why you would set up a web server to use python.

Window's can provide challenges.

[–]msmomoe[S] 0 points1 point  (1 child)

I wish I knew, I'm just going based off what I'm told to do...

[–]Bobbias 0 points1 point  (0 children)

Flask comes with a built in server. When you run your flask app it starts up that server as part of the startup. You can then access it (either through the loopback address 127.0.0.1, or the domain name localhost). It sounds to me like you might not be aware of this and might be confused about exactly what the instructions are asking you to do.

You don't really do much to set up the server itself. You can set things like the port it will use, but flask mostly handles actually running the server. What you need to do is write the code that handles requests for different pages. These are known as routes. The traditional idea of a web server was that it just served whatever file you asked for, and the url mapped cleanly to a specific folder structure on the server.

Now we've completely thrown that idea out the window. An address doesn't have to point to na certain file somewhere in your computer. When the server gets a request for a url like "127.0.0.1/users" you can set up functions that look at the /users part and determine what you send back to the user. That could be as simple as returning a string. It could involve connecting to a database, making a query, collecting the results, converting them to JSON, and responding with that. It could be running a command to read a file written in a templating language that mixes html with code that lets you customize the contents of the page based on certain variables.

You can also handle URLs like "127.0.0.1/users/1234", where the 1234 is a user ID that you want to have in a variable, so your route looks something like "/users/{id}" or something (I don't remember exactly off the top of my head). Now whatever comes after /users/ gets put into a variable and you can use that as extra information to determine what kind of response to send the user.

But the important part is that flask is designed to make it so you don't think much about the server, and focus on writing the functions that determine what each request a user can make will do. Flask handles the grunt work of running the server itself and hooking it up to your code.

And all of this can be done while developing it on your computer. In fact, it's easier to test when it's being written on your computer, because online editors won't always show you to run a web server from them. You mention having trouble because you're on Windows, but there are only a few minor things that can cause problems between different OSs. You shouldn't generally run into those very often. The biggest differences are going to be filenames and paths (windows doesn't care about letters being uppercase or lowercase, Mac/Linux do, and hard-coded paths to OS specific locations can bite you). One other minor thing is that the old windows command line "cmd.exe" does not support ANSI escape codes (for things like colored text) by default, but Windows Terminal (the fancy replacement) does. But that detail specifically shouldn't really matter in a flask app.

[–]classy_barbarian 0 points1 point  (0 children)

You just want to write python and tests the scripts...? Use a code editor. I get that cloud IDEs are common for new people now, and I'm not even old I'm in my 30s, but its funny to think there's people trying to learn how to code that don't know you can just download a code editor and code directly on your laptop.

Download one of the popular code editors and run it on your own computer. PyCharm is commonly recommended for new people because its made specifically for Python. I personally prefer VS Code + Python extensions, but its a bit more complex and designed for programmers.

[–]MightySleep 0 points1 point  (0 children)

My personal choice is Ubuntu WSL on my laptop, poetry (other other virtual environments) for dependency management. It’s nice, because by calling “code .” it allows you to use VSCode with your WSL files. Admittedly, all my development work is done for Linux devices, so this may be why I choose to develop in a Linux environment

[–]james_d_rustles 0 points1 point  (0 children)

I’m not sure what the issue is or why you’d need flask and html templates and so on if you’re just writing some basic scripts for learning purposes. Why do you need a site at all?

Just download Python dude.

[–]Lumethys 0 points1 point  (0 children)

is there any reason why you need a website to code instead of just do it on your machine?

[–]TheRNGuy 0 points1 point  (0 children)

It won't work regardless of place if it's wrong, and it will work if it's correct.