在本文中,您将会了解到关于在Windows上使用Python/Django运行服务器时,是否可以使用自定义测试url进行测试?的新资讯,并给出一些关于$str=asdfasdf123541[url]a
在本文中,您将会了解到关于在 Windows 上使用 Python/Django 运行服务器时,是否可以使用自定义测试 url 进行测试?的新资讯,并给出一些关于$str =asdfasdf123541[url]asdfasdf[/url]cxgew435asdfasdf; [url]asdfasdf[/url] 想把这块去掉,最好的方法是什么。、DigitalOcean 应用程序平台:在非根 URL 上使用 Gunicorn 托管 Dockerized Django 应用程序、Django URL 错误:website.urls 中定义的 URLconf,Django 尝试了这些 URL 模式、Firebase 存储 - URL 上的文件:无法访问确保文件 url 不是目录、符号链接或无效的 url的实用技巧。
本文目录一览:- 在 Windows 上使用 Python/Django 运行服务器时,是否可以使用自定义测试 url 进行测试?
- $str =asdfasdf123541[url]asdfasdf[/url]cxgew435asdfasdf; [url]asdfasdf[/url] 想把这块去掉,最好的方法是什么。
- DigitalOcean 应用程序平台:在非根 URL 上使用 Gunicorn 托管 Dockerized Django 应用程序
- Django URL 错误:website.urls 中定义的 URLconf,Django 尝试了这些 URL 模式
- Firebase 存储 - URL 上的文件:无法访问确保文件 url 不是目录、符号链接或无效的 url
在 Windows 上使用 Python/Django 运行服务器时,是否可以使用自定义测试 url 进行测试?
如何解决在 Windows 上使用 Python/Django 运行服务器时,是否可以使用自定义测试 url 进行测试?
我习惯了 PHP/Apache,因为我可以在 Windows 主机文件中添加一个条目并访问它,而不是使用 localhost url。例如,
Windows > hosts file > 127.0.0.1 testsite.test
然后我也在 Apache VirtualHost 指令中添加这个 testsite.test
。
我是 Python 和 Django 的新手,一直在关注一个教程,其中向我展示了如何设置 Python 和 Django,以及如何设置虚拟环境。设置完成后,它运行 python manage.py runserver
,在 http://127.0.0.1:8000
是否可以像上面的 Apache 一样访问这个 url?
解决方法
您有两种不同的选择。第一个是通过执行 python manage.py runserver 80
在端口 80 上运行 Django runserver。这可能需要某些系统的管理权限,在这种情况下应该避免,因为将权限授予您的开发代码可能是一个安全问题(您可能会错误地破坏您的操作系统,或者有人可以远程控制您的操作系统) .
第二个选项是通过 nginx 或 apache 重定向您的 Web 服务器。一个简单的nginx配置文件:
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name example.com; # substitute your machine''s IP address or custom domain name
charset utf-8;
# max upload size
client_max_body_size 75M; # Adjust to your need
location /media {
alias /path/to/your/mysite/media; # your Django project''s media files
}
location /static {
alias /path/to/your/mysite/static; # your Django project''s collected static files
}
# Finally,send all non-media requests to the Django server.
location / {
proxy_pass http://127.0.0.1:8000;
include /etc/nginx/proxy_params; # the uwsgi_params file you installed
}
}
$str =asdfasdf123541[url]asdfasdf[/url]cxgew435asdfasdf; [url]asdfasdf[/url] 想把这块去掉,最好的方法是什么。
[url]asdfasdf[/url] 想把这块去掉,最好的方法是什么。
DigitalOcean 应用程序平台:在非根 URL 上使用 Gunicorn 托管 Dockerized Django 应用程序
如何解决DigitalOcean 应用程序平台:在非根 URL 上使用 Gunicorn 托管 Dockerized Django 应用程序?
我最近在 DigitalOcean 应用程序平台上部署了一个 dockerized Django 应用程序,以及使用应用程序规范文件的 react 静态站点。由于是静态站点,我选择在非根 URL(例如 https://example.com/api
)上提供 Django,并在根 URL (https://example.com
) 上提供 react 应用程序。
如果我访问 Django URL,Django 会出现但抛出“找不到路径错误”。我的 Django 应用程序上的所有路由都不起作用。解决方案似乎也没有在 google 上,我不知道为什么。
这是我的 app.yaml 的样子:
name: test
region: nyc
services:
- name: backend-api
github:
branch: deployment_app_platform
repo: NdibeRaymond/test
deploy_on_push: true
http_port: 8000
instance_count: 1
instance_size_slug: basic-xxs
source_dir: backend/
dockerfile_path: backend/compose/django/Dockerfile
routes:
- path: /api
static_sites:
- name: frontend
environment_slug: node-js
github:
branch: deployment_app_platform
repo: NdibeRaymond/test
deploy_on_push: true
source_dir: frontend/test/
build_command: npm run build
routes:
- path: /
gunicorn 配置
exec /usr/local/bin/gunicorn test.wsgi --threads=3 --bind 0.0.0.0:8000 --chdir /backend/test
根网址文件
urlpatterns = [
path(''admin/'',admin.site.urls),path(''api-auth/'',include(''rest_framework.urls'')),path(''summernote/'',include(''django_summernote.urls'')),path('''',include(''APIS.urls'')),] + static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
我也试过
urlpatterns = [
path(''api/admin/'',path(''api/api-auth/'',path(''api/summernote/'',path(''api/'',document_root=settings.MEDIA_ROOT)
你能发现我遗漏了什么吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
Django URL 错误:website.urls 中定义的 URLconf,Django 尝试了这些 URL 模式
如何解决Django URL 错误:website.urls 中定义的 URLconf,Django 尝试了这些 URL 模式
我正在我自己的域上使用 Nginx/gunicorn 在 ubuntu 数字海洋水滴上运行 django 项目。我正在使用 Django 3.1.6 版和 Python 3.8.5 的虚拟环境
我正在尝试按照 Corey Shafers Django tutorial 创建一个博客应用程序,虽然我可以访问 example.com 上的通用 django 成功页面,但我从 example.com/blog 遇到了以下内容:
找不到页面 (404) 请求方式:GET 请求网址:example.com/blog 使用在 website.urls 中定义的 URLconf,Django 按以下顺序尝试了这些 URL 模式:
管理员/ 当前路径,博客,与这些都不匹配。
我当前的 ~/projectdir/website/urls.py(见底部编辑):
from django.contrib import admin
from django.urls import path,include
urlpatterns = [
path(''admin/'',admin.site.urls),path('''',include(''blog.urls'')),]
我的 ~/projectdir/blog/urls.py:
from django.urls import path
from . import views
urlpatterns = [
path('''',views.home,name=''blog-home''),path(''about/'',views.about,name=''blog-about''),]