initial commit
This commit is contained in:
commit
184eb978b7
1
.dockerignore
Symbolic link
1
.dockerignore
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
.gitignore
|
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
venv
|
||||||
|
__pycache__
|
||||||
|
|
||||||
|
.idea
|
||||||
|
.vscode
|
7
Dockerfile
Normal file
7
Dockerfile
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
FROM python:3.10
|
||||||
|
ARG PYPI_MIRROR=https://pypi.tuna.tsinghua.edu.cn/simple
|
||||||
|
ENV PYPI_MIRROR=${PYPI_MIRROR}
|
||||||
|
ADD . /app
|
||||||
|
WORKDIR /app
|
||||||
|
RUN ./scripts/setup-env.sh
|
||||||
|
CMD /app/venv/bin/waitress-serve app:app
|
5
app/__init__.py
Normal file
5
app/__init__.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from .app import app
|
||||||
|
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
__all__ = ["app"]
|
3
app/app.py
Normal file
3
app/app.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from flask import Flask
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
13
app/templates/index.html
Normal file
13
app/templates/index.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>A Sample Python Flask Project</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div>A Sample Python Flask Project</div>
|
||||||
|
<div>{{now}}</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
3
app/views/__init__.py
Normal file
3
app/views/__init__.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import flask
|
||||||
|
|
||||||
|
from . import simple_views
|
15
app/views/simple_views.py
Normal file
15
app/views/simple_views.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
import os
|
||||||
|
from ..app import app
|
||||||
|
from flask import Blueprint, render_template
|
||||||
|
|
||||||
|
simple_views = Blueprint("views", __name__, template_folder=os.path.join(
|
||||||
|
os.path.dirname(__file__), "templates"))
|
||||||
|
|
||||||
|
|
||||||
|
@simple_views.get("/")
|
||||||
|
def index_page():
|
||||||
|
return render_template("index.html", now=datetime.now())
|
||||||
|
|
||||||
|
|
||||||
|
app.register_blueprint(simple_views)
|
2
requirements-dev.txt
Normal file
2
requirements-dev.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
autopep8
|
||||||
|
black
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Flask<3
|
||||||
|
waitress
|
23
scripts/setup-env.sh
Executable file
23
scripts/setup-env.sh
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
SCRIPTDIR=$(dirname $0)
|
||||||
|
BASEDIR=$(dirname $SCRIPTDIR)
|
||||||
|
|
||||||
|
pip_options=()
|
||||||
|
|
||||||
|
if [ ! -z "${PYPI_MIRROR}" ]; then
|
||||||
|
pip_options+=(-i "${PYPI_MIRROR}")
|
||||||
|
fi
|
||||||
|
|
||||||
|
create-venv() {
|
||||||
|
python -m venv venv
|
||||||
|
}
|
||||||
|
|
||||||
|
install-requirements() {
|
||||||
|
pip install "${pip_options[@]}" -r requirements.txt
|
||||||
|
}
|
||||||
|
|
||||||
|
pushd ${BASEDIR}
|
||||||
|
create-venv
|
||||||
|
. ./venv/bin/activate
|
||||||
|
install-requirements
|
Loading…
x
Reference in New Issue
Block a user