Create Python Flask website on Pythonanywhere


Flask is one of the light weight Python Frame work which can be used to develop awesome website

Image result for flaskwith minimal coding. Take a look at the few Flask powered website, click here

For development purpose you can simply launch on project at a time in Pythonanywhere.com, a free python hosting website.

Create Web Application

Go to your Pythonanywhere.com dashboard and locate Web Tab and add a new Application.
Choose appropriate Flask and Python version and finish the project. Your Flask project resides in Mysite folder. Go to your flask_app.py file and edit and add few lines of code for adding more urls as follows
from flask import Flask
app = Flask(__name__)
@app.route(“/”)
def index():
return “Index Page!”

@app.route(“/post”)
def post():
return “Post Page”

@app.route(“/about”)
def about():
return “About the page”

@app.route(“/contact”)
def contact():
return “Contact us”

if __name__ == “__main__”:
app.debug = True
app.run()

You can also use Console tab for advanced operations.

Let’s take a look at your flask

username.pythonanywhere.com — Index
username.pythonanywhere.com/post  — Post page
username.pythonanywhere.com/contact  — contact page

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.