Since the data previously collected in the hospital were prescription pictures obtained by taking photos, what needs to be used is the text form of the prescription. Therefore, I wrote a small program in the past two weeks to display pictures of the server to users (hiring some people at that time), allowing users to enter text information based on the pictures.
I used Java to write web pages before. I thought that I would use Python to learn machine learning recently, so I used Python to write it. In addition, because I wanted to use something new and the program was relatively small, I considered using mongodb for storage. (Although it's really not necessary).
The basic architecture is like this: (backend language) python + (web framework and web server) tornado + (database) mongodb + (process management) supervisor + (reverse proxy) nginx
(1) python: I am watching Liao Xuefeng’s python tutorial
I learned some basic sentences, and then I checked them if I didn’t understand them when I was doing them.
(2) tornado: I started learning by watching this tutorial
tornado is very fast to use. It can map requests directly like a forwarder in spring, and directly monitor http requests on a certain port like tomcat. Tornado has done all these things for us, we only need to write The get and post methods are fine.
The rest is almost the same as in java web. Without the framework of springMVC and hibernate, you can layer controller, service, and dao in the python package yourself.
(3) mongodb: Non-relational database, there is no requirement for the same field name to be unified for each row of data (called collection in mongodb) in a table (called collection in mongodb). More or less, uneven. Another point is that transactions are not supported, and there is no way to roll back when executing multiple read and write statements in Python, so you have to find a way to prevent problems caused by concurrency in the program.
For example, I need to find a document with a status of 0 from the collection and update it to 1, which means the user is viewing it. After the user makes modifications, then set the status to 2 and then put it back. Here 0 means not browsed, 1 It means it is being browsed, and 2 means it has been modified. At this time, many users may have obtained the data with status 0 at the same time. This goes against our wishes and allows many people to modify the same data. You can consider directly update_one to change the status of a document from 0 to 1, and then add a unique field to identify the document, and use this unique field to find the document. At this time, other users cannot obtain the document because update_one It will be locked when the time comes, and others cannot get this data.
(4) supervisor: Supervisor is a process management program developed in python. It can turn ordinary commands into background daemons and monitor the process status.
After installation, you can add the configuration file printprescription.conf in the /etc/supervisor/conf.d directory. The configuration example is as follows
[program:printprescription] #设置守护进程名 command = python /home/liaohuqiang/Code/printprescription/main2.py #设置执行命令 autorstart=true #设置随supervisor的启动而启动 stdout_logfile = /home/liaohuqiang/Code/printprescription/printprescription.log #设置日志路径
After the configuration is completed, you can open, close and restart the supervisor service. You can use supervisorctl status to check the process status, and you can also check the error information in the relevant log files
sudo /etc/init.d/supervisor start sudo /etc/init.d/supervisor stop sudo /etc/init.d/supervisor restart<br><br>sudo supervisorctl status printprescripton<br>vim cat /var/log/supervisor/xxx.log
(5) nginx: nginx is used as a reverse proxy. It can monitor port 80 and forward corresponding requests to other hosts and other ports. The path of the image we display here is not in tornado in static (static is used to store front-end static resources such as js and css), but in another location on the server, so the image can be obtained through nginx forwarding. On the other hand, other ports (such as the 8001 port that tornado listens on) are generally not exposed to users, so nginx is used for forwarding. In addition, the location /static/ directive tells nginx to provide static directory files directly instead of proxying requests to tornado. nginx can provide static files more efficiently than tornado.
After installing nginx, check the relevant configuration files and find this sentence: include /etc/nginx/sites-enabled/*. You can create a new configuration file in this directory for configuration
cat /etc/nginx/nginx.conf<br>sudo touch /etc/nginx/sites-enabled/default2
The configuration example is as follows. It should be noted that the bottom http://127.0.0.1:8001/ If the last slash here is not typed, the above printprescription will actually be added. When the user accesses "host/printprescription" It is equivalent to accessing "Host:8001/printprescription". Since the request on Tornado is mapped to Host:8001/, 404 will appear at this time.
<span style="color: #000000"> upstream frontends { server </span><span style="color: #800080">222.222</span>.<span style="color: #800080">222.222</span>:<span style="color: #800080">8000</span><span style="color: #000000">; server </span><span style="color: #800080">222.222</span>.<span style="color: #800080">222.222</span>:<span style="color: #800080">8001</span><span style="color: #000000">; } server { listen </span><span style="color: #800080">80</span><span style="color: #000000">; location </span>/<span style="color: #000000"> { proxy_read_timeout </span><span style="color: #800080">1800</span><span style="color: #000000">; proxy_pass_header Server; proxy_set_header Host $http_host; proxy_redirect off; proxy_set_header X</span>-Real-<span style="color: #000000">IP $remote_addr; proxy_set_header X</span>-<span style="color: #000000">Scheme $scheme; proxy_pass http:</span><span style="color: #008000">//</span><span style="color: #008000">frontends;</span> <span style="color: #000000"> } location </span>/doctorAfter/<span style="color: #000000"> { #配置图片路径 root </span>/home/<span style="color: #000000">wenserver; } location </span>/static/<span style="color: #000000"> { #配置前端静态资源路径 root </span>/home/xxx/Code/printprescription/<span style="color: #000000">view; } location </span>/printprescription/<span style="color: #000000"> { proxy_read_timeout </span><span style="color: #800080">1800</span><span style="color: #000000">; proxy_pass_header Server; proxy_set_header Host $http_host; proxy_redirect off; proxy_set_header X</span>-Real-<span style="color: #000000">IP $remote_addr; proxy_set_header X</span>-<span style="color: #000000">Scheme $scheme; proxy_pass http:</span><span style="color: #008000">//</span><span style="color: #008000">127.0.0.1:8001/;</span> <span style="color: #000000"> } }</span>
(6)opencv:一个计算机视觉库,实现了图像处理和计算机视觉方面的很多通用算法。由于之前采集数据的时候在处方图片数据中混杂了人脸图片,所以采用oepncv里的算法检测人脸,如果是人脸则删除该记录。然而还是会残留一些人脸图片,需要人工清洗,这个数据好像之前有师兄清洗过,到时候拿过来重构一下数据库。
ps:安装opencv的时候imshow报错,虽然imshow用不到,但是强迫症使然,搞了我一天,来来回回装了十多次,最后还是没搞定,真是心力交瘁,特想吐嘈:垃圾opencv!毁我青春!颓我精神!耗我时间!磨我意志!浪费人生!!!
好吧我就随便说说,回头还要靠它干活。
cv2.error: /io/opencv/modules/highgui/src/window.<span style="color: #0000ff">cpp</span>:<span style="color: #800080">583</span>: error: (-<span style="color: #800080">2</span>) The <span style="color: #0000ff">function</span> is not implemented. Rebuild the library with Windows, GTK+ <span style="color: #800080">2</span>.x or Carbon support. If you are on Ubuntu or Debian, <span style="color: #0000ff">install</span> libgtk2.<span style="color: #800080">0</span>-dev and <span style="color: #0000ff">pkg-config</span>, <span style="color: #0000ff">then</span> re-run cmake or configure script <span style="color: #0000ff">in</span> <span style="color: #0000ff">function</span> cvShowImage
The above is the detailed content of python+tornado+supervisor+nginx deployment under ubuntu. For more information, please follow other related articles on the PHP Chinese website!

IDLE(集成开发学习环境Integrated Development and Learning Environment)是一个 Python IDE,由 Python 语言本身编写,在 Windows 中通常作为 Python 安装 的一部分而安装。它是初学者的理想选择,使用起来很简单。对于那些正在学习 Python 的人,比如学生,它可以作为一个很好的 IDE 来开始使用。语法高亮、智能识别和自动补全等基本功能是这个 IDE 的一些特点。你可以随时在官方 文档 中了

如何在 Ubuntu 中切换多个 PHP 版本?下面本篇文章给大家介绍一下Ubuntu中切换多个 PHP 版本的方,希望对大家有所帮助!

1.使用快捷键【Ctrl+Alt+T】打开终端命令模式。2.可以通过以下方式重启nginx服务。方法一,在nginx可执行目录sbin下,输入以下命令重启/nginx-sreload#重启方法二,查找当前nginx进程号,然后输入命令:kill-HUP进程号,实现重启nginx服务#ps-ef|grepnginx#查找当前nginx进程号]#kill-TERM132#杀死nginx进程,132为nginx进程号

docker内ubuntu乱码的解决办法:1、通过“locale”查看本地使用的语言环境;2、通过“locale -a”命令查看本地支持的语言环境;3、在“/etc/profile”文件的结尾处添加“export LANG=C.UTF-8”;4、重新加载“source /etc/profile”即可。

查找无用的镜像首先,您可以检查当前使用的内核,您可以通过命令获得信息:uname-aa.例如,它在我的桌面上显示为:复制代码代码如下:magc@magc-desktop:~$uname-aLinuxmagc-desktop2.6.24-19-RT#1SMPpremptRTThu8月21日02:08336003UTC2008i686GNU/Linux然后通过查看这台机器上所有内核的列表来决定哪些需要删除:运行命令:复制代码代码如下:dpkg-get-selections|greplinux例如,我

ubuntu php无法启动服务的解决办法:1、在php-fpm.conf里面设置错误日志;2、执行“/usr/sbin/php-fpm7.4 --fpm-config /etc/php/fpm/php-fpm.conf”命令;3、修改php的配置文件注释即可。

ubuntu没有php-fpm的解决办法:1、通过执行“sudo apt-get”命令添加php的源地址;2、查看有没有php7的包;3、通过“sudo apt-get install”命令安装PHP;4、修改配置监听9000端口来处理nginx的请求;5、通过“sudo service php7.2-fpm start”启动“php7.2-fpm”即可。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver CS6
Visual web development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
