# Where is the server code? I would like to create a Python version of it

**URL:** <https://discuss.prosemirror.net/t/where-is-the-server-code-i-would-like-to-create-a-python-version-of-it/35>\
**Category:** Uncategorized\
**Created:** [October 1, 2015, 7:11pm UTC](https://discuss.prosemirror.net/t/where-is-the-server-code-i-would-like-to-create-a-python-version-of-it/35 "2015-10-01T19:11:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![johanneswilm](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/johanneswilm/32/19_2.png) [@johanneswilm](https://discuss.prosemirror.net/u/johanneswilm)\
**Post date:** [October 1, 2015, 7:11pm UTC](https://discuss.prosemirror.net/t/where-is-the-server-code-i-would-like-to-create-a-python-version-of-it/35/1 "2015-10-01T19:11:52Z")

</div>

Is the code of your mini server to be found anywhere in the code? I would like to translate it to python and make it work with Django/websockets. I tried to look a bit, but did find it.

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [October 1, 2015, 7:27pm UTC](https://discuss.prosemirror.net/t/where-is-the-server-code-i-would-like-to-create-a-python-version-of-it/35/2 "2015-10-01T19:27:49Z")

</div>

It’s in the [website repository](https://github.com/ProseMirror/website/tree/master/src/server), tangled up with the annotation feature. Porting it to Python is not really an option, unless you want to port the whole `model` and `transform` modules (and don’t do that). You could set up a very simple Python server that simply relays JSON changes between clients, but it won’t be able to turn those changes into a full representation of the document unless it has access to an implementation of my document model.

---

<div class="post-metadata">

**Author:** ![johanneswilm](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/johanneswilm/32/19_2.png) [@johanneswilm](https://discuss.prosemirror.net/u/johanneswilm)\
**Post date:** [October 1, 2015, 7:33pm UTC](https://discuss.prosemirror.net/t/where-is-the-server-code-i-would-like-to-create-a-python-version-of-it/35/3 "2015-10-01T19:33:32Z")

</div>

Right, I thought relaying would probably be enough. Possibly stopping some packages from going through under specific conditions, but other than that nothing.

The way we have it set up now (pre-prosemirror) is that the python code simply relays the messages around and appoints one of the connected browsers to be the “master brain” to figure out about merging and to decide what goes into the document in what order, etc. . If that browser disconnected, the backend simply appoints another browser to take over as “master brain”, etc. . Would that also be how we should do it when using Prosemirror?

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [October 1, 2015, 7:36pm UTC](https://discuss.prosemirror.net/t/where-is-the-server-code-i-would-like-to-create-a-python-version-of-it/35/4 "2015-10-01T19:36:21Z")

</div>

> [@johanneswilm](#):
>
> Would that also be how we should do it when using Prosemirror?

If you are fully aware of the security implications, sure, that would work. You’ll want to have the master peer send a full version of the document to the server now and then, so that it can save it.

---

<div class="post-metadata">

**Author:** ![johanneswilm](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/johanneswilm/32/19_2.png) [@johanneswilm](https://discuss.prosemirror.net/u/johanneswilm)\
**Post date:** [October 1, 2015, 8:00pm UTC](https://discuss.prosemirror.net/t/where-is-the-server-code-i-would-like-to-create-a-python-version-of-it/35/5 "2015-10-01T20:00:56Z")

</div>

> [@marijn](#):
>
> If you are fully aware of the security implications, sure, that would work.

The implication being that the master can do malicious changes to the document? Yes, I am aware of that. Given that the server is channeling all the information back and forth, it should have any private information about the other participants, right?

Only when the document is saved would I do some rudimentary checks on whether something odd has happened to it. Those checks would be on the server.

> [@marijn](#):
>
> You’ll want to have the master peer send a full version of the document to the server now and then, so that it can save it.

Yes, that’s also how we have it now.

But is this the recommended way of doing it? I will have to change a lot of code anyway, and if there is little need for us to keep custom and odd behavior if there are better ways around.

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [October 1, 2015, 8:14pm UTC](https://discuss.prosemirror.net/t/where-is-the-server-code-i-would-like-to-create-a-python-version-of-it/35/6 "2015-10-01T20:14:13Z")

</div>

If you’re open to running a node process on your server, I think things could be saner by having the server be the authority.

---

<div class="post-metadata">

**Author:** ![johanneswilm](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/johanneswilm/32/19_2.png) [@johanneswilm](https://discuss.prosemirror.net/u/johanneswilm)\
**Post date:** [October 1, 2015, 8:53pm UTC](https://discuss.prosemirror.net/t/where-is-the-server-code-i-would-like-to-create-a-python-version-of-it/35/7 "2015-10-01T20:53:28Z")

</div>

> [@marijn](#):
>
> If you’re open to running a node process on your server, I think things could be saner by having the server be the authority.

Eventually we will probably do that, and we may even switch entirely to node.js on the backend. But just to keep the change as simple as possible, I will go for the above solution, as that is more or less what we are doing already.\<

Thanks for the advice!
