Skip to content

Commit

Permalink
first commit flask.
Browse files Browse the repository at this point in the history
  • Loading branch information
lesliebinbin committed Aug 20, 2018
0 parents commit 19af778
Show file tree
Hide file tree
Showing 11 changed files with 223 additions and 0 deletions.
117 changes: 117 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}"
},
{
"name": "Python: Attach",
"type": "python",
"request": "attach",
"localRoot": "${workspaceFolder}",
"remoteRoot": "${workspaceFolder}",
"port": 3000,
"secret": "my_secret",
"host": "localhost"
},
{
"name": "Python: Terminal (integrated)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Python: Terminal (external)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "externalTerminal"
},
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"runserver",
"--noreload",
"--nothreading"
],
"debugOptions": [
"RedirectOutput",
"Django"
]
},
{
"name": "Python: Flask (0.11.x or later)",
"type": "python",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "app.py"
},
"args": [
"run",
"--no-debugger",
"--no-reload"
]
},
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "module.name"
},
{
"name": "Python: Pyramid",
"type": "python",
"request": "launch",
"args": [
"${workspaceFolder}/development.ini"
],
"debugOptions": [
"RedirectOutput",
"Pyramid"
]
},
{
"name": "Python: Watson",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/console.py",
"args": [
"dev",
"runserver",
"--noreload=True"
]
},
{
"name": "Python: All debug Options",
"type": "python",
"request": "launch",
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"module": "module.name",
"env": {
"VAR1": "1",
"VAR2": "2"
},
"envFile": "${workspaceFolder}/.env",
"args": [
"arg1",
"arg2"
],
"debugOptions": [
"RedirectOutput"
]
}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.pythonPath": "/home/leslie/Desktop/python3_config/bin/python",
}
Binary file added __pycache__/app.cpython-36.pyc
Binary file not shown.
37 changes: 37 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python3
# coding:utf-8
from flask import Flask, render_template, request
from flask_bootstrap import Bootstrap
from flask_moment import Moment
app = Flask(__name__)
bootstrap = Bootstrap(app=app)
moment = Moment(app=app)

@app.route("/")
def index():
return render_template("index.html")


@app.route('/user/<name>')
def user(name):
age = request.args.get("age")
return render_template('user.html', name=name, age=age)


@app.route('/inheritance')
def inheritance():
return render_template('inheritance.html')


@app.errorhandler(404)
def page_not_found(e):
return render_template('404.html'), 404


@app.errorhandler(500)
def internal_server_error(e):
return render_template('500.html'), 500


if __name__ == "__main__":
app.run(host='0.0.0.0', port=8080, debug=True)
Binary file added static/favicon.ico
Binary file not shown.
6 changes: 6 additions & 0 deletions templates/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% extends "base.html" %} {% block title %} Flasky - Page Not Found {% endblock title
%} {% block page_content %}
<div class="page-header">
<h1>Not Found</h1>
</div>
{% endblock page_content %}
6 changes: 6 additions & 0 deletions templates/500.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% extends "base.html" %} {% block title %} Flasky - Server Internal Error {% endblock
title %} {% block page_content %}
<div class="page-header">
<h1>Server Internal error</h1>
</div>
{% endblock page_content %}
23 changes: 23 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% extends "bootstrap/base.html" %} {% block title %} Flasky {% endblock title %}
{% block head %} {{super()}} {{moment.include_moment()}}
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}"
type="image/x-icon">
<link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}" type="image/x-icon"> {% endblock head %} {% block navbar %}
<div class="navbar navbar-inverse" role="navigation">
<div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class=></span>
</button>
<a href="/" class="navbar-brand">Flasky</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="/">Home</a></li>
</ul>
</div>
</div>
{% endblock navbar %} {% block content %}
<div class="container">
{% block page_content %} {% endblock page_content %}
</div>
{% endblock content %}
13 changes: 13 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>My first awesome Flask</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
</head>
<body>
<h1>Hello Flask!</h1>
</body>
</html>
11 changes: 11 additions & 0 deletions templates/inheritance.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{%extends "base.html" %}
{%block title%}
Base
{%endblock%}
{%block head%}
{{super()}}
<style></style>
{%endblock%}
{%block body%}
<h1>Just to see the fucking jinja.</h1>
{%endblock%}
7 changes: 7 additions & 0 deletions templates/user.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% extends "base.html" %} {% block title %} Flasky {% endblock title %} {% block
page_content %}
<h1>
Hello,{{name}}
You age is {{age}}!!
</h1>
{% endblock page_content %}

0 comments on commit 19af778

Please sign in to comment.