Skip to content

thinkphp/flask-pythonanywhere

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 

Repository files navigation

Flask Web Framework

Flask is a web framework, it’s a Python module that lets you develop web applications easily. It’s has a small and easy-to-extend core: it’s a microframework that doesn’t include an ORM (Object Relational Manager) or such features.

http://thinkphp.pythonanywhere.com/

  • python3 -V
  • sudo apt install python3-venv
  • mkdir flask_app && cd flask_app
  • python3 -m venv venv
  • source venv/bin/activate
  • (venv) $ pip install Flask
  • (venv) $ python -m flask --version
  • (venv) $ pip freeze
  • (venv) $ export FLASK_APP=hello.py
  • (venv) $ echo $FLASK_APP
  • (venv) $ hello.py # ok
  • (venv) $ sudo ufw allow 5000
  • (venv) $ flask run --host=0.0.0.0 --port=5000 #run in container
from flask import Flask
app = Flask(__name__)

@app.route("/")
def index():
    return "Frank Sinatra"

Run Flask app as 0.0.0.0

export FLASK_APP=app.py

echo $FLASK_APP

flask run --host=0.0.0.0 0 --port=3000

Template

from flask import Flask, render_template

app = Flask(__name__)

@app.route("/")
def index():
    pagetitle = "HomePage"
    return render_template("index.html",
                            mytitle=pagetitle,
                            mycontent="Hello World")
myproject/
    /app/
        /templates/
            /index.html
        /views.py
        
index.html
<html>
    <head>
        <title>{{ mytitle }}</title>
    </head>
    <body>
        <p>{{ mycontent }}</p>
    </body>
</html>

Reference

About

Python Flask Minimalistic Pythonanywhere

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published