Skip to content

Commit

Permalink
Merge pull request #2 from FafnerKeyZee/main
Browse files Browse the repository at this point in the history
Enjoying Poetry \o/
  • Loading branch information
adulau committed Oct 30, 2023
2 parents 39bae95 + 696f3c6 commit f09a6e2
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 8 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ mmdb-server includes a free and open [GeoOpen-Country database](https://data.pub

# Installation

Python 3.8+ is required to run the mmdb-server with some [additional requirements](./REQUIREMENTS).
Python 3.10+ is required to run the mmdb-server with poetry.

- `pip3 install -r REQUIREMENTS`
- `curl -sSL https://install.python-poetry.org | python3 -`
- Log out and Log in again
- `poetry install`
- `cp ./etc/server.conf.sample ./etc/server.conf`
- `cd ./db; bash update.sh; cd ..` (to get the latest version of the GeoOpen database)
- `cd bin; python3 server.py`
- `poetry run serve`

# Usage

Expand Down
2 changes: 0 additions & 2 deletions REQUIREMENTS

This file was deleted.

1 change: 0 additions & 1 deletion _config.yml

This file was deleted.

Empty file added mmdb_server/__init__.py
Empty file.
9 changes: 7 additions & 2 deletions bin/server.py → mmdb_server/mmdb_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

version = "0.5"
config = configparser.ConfigParser()
config.read('../etc/server.conf')
config.read('etc/server.conf')
mmdb_file = config['global'].get('mmdb_file')
pubsub = config['global'].getboolean('lookup_pubsub')
port = config['global'].getint('port')
Expand Down Expand Up @@ -121,7 +121,12 @@ def on_get(self, req, resp):
app.add_route('/geolookup/{value}', GeoLookup())
app.add_route('/', MyGeoLookup())

if __name__ == '__main__':
def main():
with make_server('', port, app) as httpd:
print(f'Serving on port {port}...')
httpd.serve_forever()


if __name__ == '__main__':
main()

57 changes: 57 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[tool.poetry]
name = "mmdb-server"
version = "0.5.0"
description = ""
authors = ["Alexandre Dulaunoy"]
readme = "README.md"

[tool.poetry.scripts]
serve = "mmdb_server.mmdb_server:main"

[tool.poetry.dependencies]
python = "^3.10"
falcon = "^3.1.1"
maxminddb = "^2.4.0"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

0 comments on commit f09a6e2

Please sign in to comment.