我有 FastAPI 应用程序在 docker docker 容器中运行。它运行良好,除了一件事之外,如果源代码中进行任何更改,应用程序不会重新加载。仅当容器重新启动时,更改才会应用。
这是我的应用程序的源代码,那么如何确保每次对源代码进行一些更改时我的容器化应用程序都会自动重新加载?
主要.py
from typing import Optional
import uvicorn
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: Optional[str] = None):
return {"item_id": item_id, "q": q}
if __name__ == '__main__':
uvicorn.run(app, host="0.0.0.0", port=8000, reload=True)
Run Code Online (Sandbox Code Playgroud)
docker-compose.yml
version: "3"
services:
web:
build: .
restart: always
command: bash -c "uvicorn main:app --host 0.0.0.0 --port 8000 --reload"
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db
db:
image: postgres
ports: …Run Code Online (Sandbox Code Playgroud) 我正在尝试根据官方文档上的说明进行 v-select,但我的数据比文档中显示的更加嵌套,我无法在 v-select 中显示我的数据的llcName,并且我坚持这个。
这是我的 html div 和 Vue 实例,数据如下
<div id="vs">
<h1>Vue Select</h1>
<v-select multiple :options="options" :reduce="node=> node.llcName" label='llcName' v-model='selected' />
<pre>[[$data]]</pre>
</div>
<script>
Vue.component('v-select', VueSelect.VueSelect)
new Vue({
el: '#vs',
delimiters: ["[[", "]]"],
data: {
options: [
{
"node": {
"id": "U3VwcGxpZXJPYmplY3Q6MzA1",
"llcName": "new",
"suppPayment": {
"edges": [0]
}
}
},
{
"node": {
"id": "U3VwcGxpZXJPYmplY3Q6MzA2",
"llcName": "new2",
"suppPayment": {
"edges": [1]
}
}
},
{
"node": {
"id": "U3VwcGxpZXJPYmplY3Q6MzA3",
"llcName": "rteer",
"suppPayment": {
"edges": [2]
} …Run Code Online (Sandbox Code Playgroud) 我尝试在 python 中使用 googledrive api v3 来使用官方 google 指令中的代码更新 googledrive 上的文件。
但我收到一个错误:
资源主体包括不可直接写入的字段。
怎么解决呢?
这是我尝试使用的代码:
try:
# First retrieve the file from the API.
file = service.files().get(fileId='id_file_in_google_drive').execute()
# File's new metadata.
file['title'] = 'new_title'
file['description'] = 'new_description'
file['mimeType'] = 'application/pdf'
# File's new content.
media_body = MediaFileUpload(
'/home/my_file.pdf',
mimetype='application/pdf',
resumable=True)
# Send the request to the API.
updated_file = service.files().update(
fileId='id_file_in_google_drive',
body=file,
media_body=media_body).execute()
return updated_file
except errors:
print('An error occurred: %s')
return None
Run Code Online (Sandbox Code Playgroud)