Coder Social home page Coder Social logo

flask-pythonanywhere's Introduction

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

flask-pythonanywhere's People

Contributors

thinkphp avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.