什么是 ASCII-Generator.site ?
ASCII-Generator.site
是一个 Django
网站,用于从图像或文本中生成 ASCII
艺术字符图 🎨
什么是 Django ?
Django
是用 Python
写的一个自由和开放源码的 WEB
程序框架,采用了MTV
的框架模式,即模型 M
,视图 V
和 模版 T
。能帮助你更快、更容易地开发 WEB
站点。
官方体验地址:https://ascii-generator.site/
安装
在群晖上以 Docker 方式安装。
在注册表中搜索 asciigen
,选择第一个 wbsu2003/asciigen
,版本选择 latest
。
端口
直接用了默认的端口 1234
运行
在浏览器中输入 http://群晖IP:1234
就能看到主界面,下面是隐私策略,点 I Agree
即可
Image to ASCII
顶部可以选择 Image to ASCII
或者 Text to ASCII
,默认是 Image to ASCII
,选择一张黑白图片
为了方便说明,老苏把官方的动图做了处理,分成了几段
试试彩图
老苏上传了一张明星的照片,能看出来是谁嘛?
谜底在文末揭晓
Text to ASCII
Text to ASCII
只要输入转变的文字即可,但是并不支持中文
继续动图
构建镜像
考虑到大部分人对构建不感兴趣,老苏这次把构建部分放到了后面
Dockerfile
是基于项目源代码构建的,做了比较多的优化,主要是都换成了国内源,解决了构建速度慢、构建不成功的问题,另外将镜像从 2G
减到了 1G
,后续将会成为老苏构建 Python
、Django
项目的模板
感觉还有进一步优化的空间,慢慢来
FROM python:3.8-slim
LABEL maintainer=laosu<wbsu2003@gmail.com>
# set work directory
WORKDIR /ags
COPY ./requirements.txt /ags
# set environment variables
## 防止 Python 将 pyc 文件复制到容器中
ENV PYTHONDONTWRITEBYTECODE 1
# 确保将 Python 输出记录到终端,从而可以实时监控 Django 日志。
ENV PYTHONUNBUFFERED 1
# Environment
# 可更换的源:
# 1.阿里源:mirrors.aliyun.com
# 2.清华源:mirrors.tuna.tsinghua.edu.cn
# 3.网易源:mirrors.163.com
#RUN sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list \
RUN sed -i s@/deb.debian.org/@/mirrors.163.com/@g /etc/apt/sources.list \
&& rm -Rf /var/lib/apt/lists/* \
&& apt-get clean \
&& apt-get -y update --fix-missing -o Acquire::http::No-Cache=True \
&& apt-get install -y python3-pip python3-opencv libpq-dev
# 可更换的源:
# 1.清华源:https://pypi.tuna.tsinghua.edu.cn/simple
# 2.豆瓣源:http://pypi.douban.com/simple
# 3.阿里源:https://mirrors.aliyun.com/pypi/simple
# 4.腾讯源:http://mirrors.cloud.tencent.com/pypi/simple
RUN pip install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com \
&& pip install -r requirements.txt
# copy project
COPY . /ags
RUN chmod +x manage.py
# Application
EXPOSE 1234
CMD ["python", "manage.py", "runserver", "0.0.0.0:1234"]
构建镜像和容器运行的基本命令如下👇
git clone https://github.com/hermanTenuki/ASCII-Generator.site.git ags
git clone https://hub.fastgit.org/hermanTenuki/ASCII-Generator.site.git ags
cd ags
docker build -t wbsu2003/asciigen:v1 .
docker run -d \
--name=wbsu2003-asciigen1 \
-p 1234:1234 \
wbsu2003/asciigen:v1
谜底揭晓
参考文档
hermanTenuki/ASCII-Generator.site: Django website for generating ASCII-arts out of images or text 🎨
地址:https://github.com/hermanTenuki/ASCII-Generator.site
在 docker 中运行 apt-get update 报错 returned a non-zero code: 100 - Rioka - 博客园
地址:https://www.cnblogs.com/rioka/p/13821598.html
How to Create Django Docker Images | Engineering Education (EngEd) Program | Section
地址:https://www.section.io/engineering-education/django-docker/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)