Forums

Tutorial for the web app function?

I'm new to python and working through a book. I've reached the stage where I need a web server that can process python. For reasons I won't go into here I don't have the ability to set up IIS or Apache locally so I tried the web app function here and quickly hit a brick wall. I don't know what the packages are and tried a basic config which let me set up static pages, but instead of running the .py file it just cats it. Is there a how to guide available that doesn't assume familiarity with django etc (trying to learn one thing at a time)? Flipping ahead in the book I don't think I'll need anything too crazy, just the ability to host html files and python scripts. Thanks

For simple stuff like that, Flask is a good option. We do have a beginner-focused tutorial on setting up Flask on PythonAnywhere -- it goes into some depth with database configuration etc., but that doesn't come in until about halfway through -- the initial stages just walk you through getting a website up and running that can call some Python code when a specific button is clicked. So if you do just those first few steps and then stop when it gets on to the database stuff, you'll probably be in a good position to adapt the code to run functions from your script instead of the "add a comment to a list" stuff that it does.

Thanks for the help. I tried setting up flask as in the guide. but I'm getting the same thing as the non flask config. If I set up a static file entry it cats the script instead of running it, and will serve out an html file. If I call the script without the the static entry it cats the script and I get file not found on the html. To follow the examples in the book I need to be able to feed the path to a web browser and have the script run. The guide seems geared towards a much more complicated project with version control and whatnot. I just need simple files served. Guess I'll skip the current project and see if later chapters can get to scripts through html.

Ugh no dice. I can set up the html file and script for the next chapter, the html is served but the script is cat instead of run.

There is simpler, more specific documentation here: http://help.pythonanywhere.com/pages/Flask/

That actually looks worse than what I've got. Is there no way to just run simple scripts without setting up virtual servers and re coding everything? I'm trying to follow the examples the book gives me not reinvent the wheel. I'm way too new to this material to reverse engineer the example scripts.

I'm afraid that Flask is as simple as it gets on PythonAnywhere.

Doh. Looks like I'm finished with my book a little earlier than anticipated (the chapter after the web stuff deals with tkinter which is localhost or bust). I'll read through the examples and hope I've got the gist. Growing a skill set while broke is a steep hill to climb. Thanks for the help.