Add info on how to run

main
Micke Nordin 4 years ago
parent 2e8b87103f
commit df7267af48

@ -1,2 +1,15 @@
# gmnd
My gemini server
# gMNd
gMNd is my gemini server, which is written in python.
Currently it only serves static files. You can build and run it from the supplied Dockerfile if you so whish
```
docker build -t gmnd:latest .
```
By just running it, it will create self signed certs and serve example content from this repo
```
docker run -p 1965:1965 gmnd
```
A slightly more interesting thing it can do is serve your own content, in this example from /tm/content on your host machine
```
docker run --mount type=bind,source="/tmp/content,target=/app/content" -p 1965:1965 gmnd
```

@ -0,0 +1,4 @@
# Heading test
* item
* item 2

@ -0,0 +1,2 @@
# Text
Plain text me old son

@ -1,4 +1,5 @@
import logging
import mimetypes
import os
import socket
import ssl
@ -48,6 +49,11 @@ class gMNd:
header = get_header()
body = b""
if os.path.isfile(self.base_path + path):
if not path.endswith(".gmi"):
header = get_header(
'20',
mimetypes.guess_type(
self.base_path + path)[0].encode())
cfile = open(self.base_path + path)
body = cfile.read().encode()
cfile.close()
@ -71,7 +77,7 @@ class gMNd:
conn.shutdown(socket.SHUT_RDWR)
conn.close()
def get_dir_list(self,directory):
def get_dir_list(self, directory):
contents = b"#Contents:\r\n"
dirs = []
files = []
@ -90,10 +96,10 @@ class gMNd:
return contents
def get_header(status='20', meta = b""):
def get_header(status='20', meta=b"text/gemini"):
metadict = {}
metadict['10'] = meta
metadict['20'] = b"text/gemini"
metadict['20'] = meta
metadict['30'] = meta
metadict['40'] = meta
metadict['50'] = meta
@ -105,5 +111,8 @@ def get_header(status='20', meta = b""):
if __name__ == "__main__":
server = gMNd({'allow_dir_list': True, 'logg_level': logging.DEBUG, 'listen_addr': '0.0.0.0'})
server = gMNd({
'allow_dir_list': True,
'listen_addr': '0.0.0.0'
})
server.run()

Loading…
Cancel
Save