Giter VIP home page Giter VIP logo

upload-pictures-vps-public's Introduction

Uplaod-Pictures-VPS-Publuc

上传⏫图片到 VPS 服务器

上传图片的后端账号和密码都是:admin

要修改,请修改 /app/main.py 文件。

# 把文件中这一行的代码中的 admin 改为你想要的密码就行

if credentials.username != "admin" or credentials.password != "admin":

所需环境请到 搭建在线 Blog & 超详细配置 进行查阅

*** 另外还需要在 /app/ 路径的同级下创建一个 /blog/assets/ 文件夹📂路径,以放上传的图片 ***

安装好所需要的包之后,请运行以下命令进行 FastAPI 的运行

uvicorn main:app --host 0.0.0.0 --port 8011 --reload

# 其中 8011 为 main.py 中设置的 端口。

如果不需要使用 Nginx 的话,请在浏览器中输入(0.0.0.0为你的 VPS 的 IP):http://0.0.0.0:8011/api/docs

假设你做 Nginx 的配置,那么地址是:http://www.xxx.xxx/api/docs

附上我的 Nginx 关键配置部分

       server {
           listen       80;
           listen       [::]:80;
           server_name  www.xxx.xxx;
           root         /usr/share/nginx/html;

           include /etc/nginx/default.d/*.conf;

           error_page 404 /404.html;
                location = /404.html {
           }

           error_page 500 502 503 504 /50x.html;
                location = /50x.html {
           }

            # fastapi 此处的 8011 是 Upload-Pitures-VPS-Public 中 /app/main.py 文件里配置好的 端口号
           location /api/docs {
               proxy_pass http://127.0.0.1:8011;
           }

           location /openapi.json {
               proxy_pass http://127.0.0.1:8011/openapi.json;
           }

           location /api/pictures {
               proxy_pass http://127.0.0.1:8011/api/pictures;
           }
       }
    }

*** 注:我没有编写删除图片的 API,可以仿照 /app/api/v1/Pictures/Pictures.py 中的方法进行编写,不然就要手动登录上 VPS 使用 rm -rf xxx.png 进行删除。 ***

另:时间仓促,没有做很好的登录校验,以及很好的前端页面去解析这个接口,以后有机会的话再细化了。

upload-pictures-vps-public's People

Contributors

sanzro-lee 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.