如何使用create-react-app处理多个页面项目?(How to work with multiple pages project with create-react-app?)
我最近在尝试create-react-app,我发现它只能处理一个名为'index.html'的默认页面。我想知道,如果我的项目是多页,我可以开发我的前端用create-react-app?怎么样?
我知道我可以使用react-router来完成我的工作,但是,我仍然希望找到一种使用create-react-app处理多个页面的方法。 我错了吗 ?I'm trying create-react-app recently,I found that it can only process one default page , which called 'index.html'.I want to know ,if my project is multiple-pages , can I develop my front-end with create-react-app?How?
I know I can use react-router to do my job ,however , I still want to find a way to process multiple pages with create-react-app. Am I wrong ?
原文:https://stackoverflow.com/questions/42074425
最满意答案
在退出程序之前调用
t2.join()
。 这等待导航线程在执行继续之前终止。编辑:
您的导航线程会立即终止,因为您没有等待子进程退出。 这应该解决问题:
process=subprocess.Popen('python navigationScript.py', \ shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) process.wait()
这将停止线程,直到子进程完成。
Call
t2.join()
before exiting your program. This waits for the navigation thread to terminate, before execution continues.Edit:
Your navigation thread terminates immediately because you are not waiting for the child process to exit. This should solve the issue:
process=subprocess.Popen('python navigationScript.py', \ shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) process.wait()
This will halt the thread until the subprocess is done.
相关问答
更多-
刚刚找到sys.executable - 当前Python可执行文件的完整路径,可用于运行该脚本(而不是依靠shbang,这在Windows上显然不起作用) import sys import subprocess theproc = subprocess.Popen([sys.executable, "myscript.py"]) theproc.communicate() Just found sys.executable - the full path to the current Python ...
-
您不能使用*因为subprocess不在shell中运行(例如Bash),而且它是将*扩展为文件列表的shell。 您可以使用shell=True来告诉subprocess在shell中运行,但这不是一个好主意 ,并且有更好的选择。 如果需要递归删除目录 ,可以使用shutil.rmtree()并避免启动子shutil.rmtree() 。 You can't use * because subprocess doesn't run in a shell (e.g. Bash), and it is the ...
-
在退出程序之前调用t2.join() 。 这等待导航线程在执行继续之前终止。 编辑: 您的导航线程会立即终止,因为您没有等待子进程退出。 这应该解决问题: process=subprocess.Popen('python navigationScript.py', \ shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) process.wait() 这将停止线程,直到子进程完成。 Cal ...
-
Python脚本异步执行其他两个python脚本(Python script executing two other python scripts asynchronously)[2022-01-18]
改为使用Popen: call()块Popen()没有 from subprocess import Popen import sys for i in range(int(sys.argv[1])): Popen(['python', 'synccall1.py']) synccall1.py try: import Tkinter as tk # for Python2 except: import tkinter as tk # for Python3 ... -
您可以使用start来执行此操作 subprocess.Popen(["start", "perl.exe", "update.pl", arg], stdin=subprocess.PIPE, shell=True) 请注意,某些程序(如notepad.exe)将在新窗口中打开,但不会创建新的cmd窗口。 您可以使用以下行测试此方法: subprocess.Popen(["start", "dir"], stdin=subprocess.PIPE, shell=True) You can use st ...
-
Popen()立即返回,因此您的父进程在您的子脚本之前很久就会完成,即在输出的最开始查找“已完成的消息”。 您不需要multiprocessing来同时运行子进程: import os import sys from subprocess import Popen # run all child scripts in parallel processes = [Popen([sys.executable, filename], cwd=dirpath) for dirpath, ...
-
您可能必须在/ etc / sudoers设置中禁用requiretty : 使用visudo命令编辑/etc/sudoers 更换: Defaults requiretty 附: Defaults !requiretty You might have to disable requiretty in your /etc/sudoers settings: Use the visudo command to edit /etc/sudoers Replace: Defaults req ...
-
使用shebang使用subprocess.call执行python脚本(Executing python scripts with subprocess.call using shebang)[2022-01-08]
您需要使用shell=True ,并且需要将您的数组转换为命令字符串,如下所示: subprocess.call(' '.join([spam, "-i", eggs, "-o", ham]), shell=True) 这将调用shell而不是直接命令,shell应该能够处理shebang。 You need to use shell=True, and you need your array to be turned into a command string, like this: subproces ... -
使用子进程PIPE在Python脚本之间发送字符串(Sending strings between to Python Scripts using subprocess PIPEs)[2022-11-02]
管道的问题在于,如果您调用读取操作并且没有任何内容可读,则代码将停止,直到另一方为您编写内容供您阅读。 此外,如果你写得太多,你的下一个写操作可能会阻塞,直到另一方从管道中读取内容并释放它。 您可以进行“非阻塞调用”,这将在这些情况下返回错误而不是阻止,但您的应用程序仍然需要明智地处理错误。 无论如何,您需要设置某种协议 。 想想HTTP或你熟悉的任何其他协议:有请求和响应,当你正在阅读这两个协议中的任何一个时,协议总是会告诉你是否还有其他需要阅读的内容。 这样,您始终可以就是否等待更多数据做出明智的决定。 ... -
你能简单地使用子进程来运行'python.exe'并将脚本管道输入吗? 或者,如果要将某些(可拾取的)数据移动到运行脚本的新进程,则多处理程序包应该足够了。 只需创建一个运行脚本的函数/可调用对象,并创建一个具有可调用目标的Process对象。 这样,您应该能够传递一些数据,而不会出现GUI问题。 使用其中任何一个捕获文本很容易,子进程允许这样做,而不是更多。 使用多进程,您可以更轻松地来回传递python对象。 Can you simply use subprocess to run 'python.ex ...