Python Forum

Full Version: Python with email forms, and frontend code in general
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys.

I'm looking to try to teach myself python practically. For example, my goal for tonight is to create an email form through python... or something similar. I was just about to buy a linux hosting package - but I just thought I should ask; is there a way of linking html with python on a frontend level locally which is relatively easy? (I'm not the sharpest tool in the shed with code yet).
(Feb-18-2018, 12:10 AM)MattH Wrote: [ -> ]is there a way of linking html with python on a frontend level locally which is relatively easy?
Use Flask it's a minimalist web-framework that's easy use and still powerful to scale from small web-app to large websites.
(Feb-18-2018, 12:10 AM)MattH Wrote: [ -> ]I was just about to buy a linux hosting package
Take a look at this post,talk a little about Python friendly host like DigitalOcean VPS, Heruko, PythonAnywhere, AWS Lambda.
Hi snippsat, firstly thanks for your scaping tutorials - they've helped me out an awful lot.

Secondly, Flask looks perfect for me right now. I've installed flask which went through perfectly.

Now I try to run in terminal using:

FLASK_APP=hello.py flask run
Which has returned the error:

Error:
Error: The file/path provided (hello.py) does not appear to exist. Please verify the path is correct. If app is not on PYTHONPATH, ensure the extension is .py Matts-MacBook-Pro:~ Matt$
I've created and put the code into hello.py as requested by Flask - does it need to be saved somewhere specific. Is that the reason for the error?

Thanks again :-)
app.py
from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "<h1><center>Hello World!</center></h1>"

if __name__ == '__main__':
   app.run(debug=True)
Now can just run it with python app.py
Example.
E:\1
λ python app.py
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 184-514-049
Go to localhost address in browser.
Look this post for a minimal setup.

The other way to run with flask run is described here
But the way shown over work fine.
I'm in!

[Image: Screen_Shot_2018_02_18_at_03_27_25.png]

Thanks again.