用于美国选举投票信息的rest api服务器

ballotapi的Python项目详细描述


ballotapi服务器

警告:此自述文件的代码尚未编写

此文件夹包含ballotapi服务器本身的代码。如果你 想要运行自己的选票api镜像,这是代码 你在找。

安装

一。安装ballotapi服务器

最简单的安装方法是通过PyPI

pip install ballotapi

要更新,只需添加-U标志。

pip install -U ballotapi

或者,您可以直接从源安装:

git clone https://github.com/open-austin/ballotapi.git
pip install -e ballotapi/

或者,您可以直接从源代码运行:

git clone https://github.com/open-austin/ballotapi.git
cd ballotapi
pip install -r requirements.txt
python3 -m ballotapi.cli --help

2.设置数据库

ballotapi服务器需要加载选票数据数据库。 你可以下载一份 test databases, 在full production database, 或者build your own

如果已经加载了数据库,则可以跳过此步骤。

# Install PostgreSQL and PostGIS plugin
sudo apt-get install postgresql postgis

# Create a BallotAPI database and user
sudo -u postgres psql -c "CREATE DATABASE ballotapi;"
sudo -u postgres psql -c "CREATE USER ballotapiuser WITH ENCRYPTED PASSWORD 'yourpasswordhere';"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE ballotapi TO ballotapiuser;"# Set database connection uri environmental variableexportBALLOTAPI_DB_URI="postgresql://ballotapiuser:yourpasswordhere@localhost:5432/ballotapi"# Load a dataset into your database
ballotapi load "testdata-default"

用法

现在已经安装了ballotapi服务器并加载了数据库, 你已经准备好运行服务器了!

ballotapi runserver

要自定义服务器的设置,请检查哪些选项 正在使用ballotapi runserver --help

usage: ballotapi runserver [-h][--db-uri URI][--cache-uri URI][--host HOST][--port PORT][--uwsgi-ini FILE][--daemon]

optional arguments:
  -h, --help        show this help message and exit
  --db-uri URI      connection uri to the postgres database (default is
                    BALLOTAPI_DB_URI env variable)
  --cache-uri URI   connection uri to a cache server (default is None)
  --host HOST       listen for this host (default localhost)
  --port PORT       listen on this port (default 1776)
  --uwsgi-ini FILE  settings for uwsgi (default is a simple http server)
  --daemon          detach server to run in background as a daemon (optional)

要在直接从命令行运行服务器时停止服务器, 只需使用Ctrl+C。停止/重新加载在后台运行的服务器 作为守护进程,向进程发送信号。

# gracefully reload
killall -s SIGHUP ballotapi

# gracefully stop
killall -s SIGTERM ballotapi

# brutally reload
killall -s SIGINT ballotapi

# brutally stop
killall -s SIGKILL ballotapi

命令

usage: ballotapi [-h] <subcommand> ...

Documentation: https://ballotapi.org/docs

optional arguments:
  -h, --help    show this help message and exit

available subcommands:
  <subcommand>
    runserver   Run the web server
    load        Load in a database from a source location
    export      Dump the database as a sql file

贡献

帮帮我们!如果你发现了一个bug或者想改进这个代码库, 请随意提交 issue 或者pull request。 查看我们的CONTRIBUTING文档了解更多详细信息。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
使用jaxrpc的Java eclipse WebService客户端   java编程方式在对象上写入名称   java Spring批处理:重试后跳过   java Android错误:错误:任务执行失败:应用程序:transformClassesWithDexForDebug'   带有清单文件nullPointerException的java Android元数据   spring Java Quartz调度作业停止运行   JavaMockito:如何在不调用实际方法的情况下,模拟带有参数和无效返回类型的静态方法?   java Tomcat连接池问题无法在关闭的连接上调用方法   java如何交换列表中的项目?   java如何停止线程并通过Toast在线程中正确显示文本?   java为什么连续写入OutputStream时偏移量0不会导致重复字节?   java我无法生成头文件   不兼容的返回类型错误java   修改值后键值对的java Jolt转换规范   java有自动更新Javadoc的工具吗?   java线程如何在ints自身实例类中共享变量   java继承一个非gwt模块   java Hibernate xml配置   使用netty4异步调用的java链接HTTP请求响应