# Application architecture
There are two ways to build your application using pywebview:
- By running a local web server
- Serverless with pywebview's JS API or
window.exposeand serving local files.
# Local web server
Running a local web server is a traditional way to build your local application. This way everything is served from a local web server and pywebview points to the URL provided by the server. In this model the server is responsible for both serving static contents and handling API calls. When building an application using a web server, you should protect your API calls against CSRF attacks. See security for more information.
See an example Flask-based application (opens new window)
- Ability to pack an existing web application as a local one.
- Easier debugging with an external browser.
- Has to rely on a third party server software for client-server communication.
- Security considerations must be taken into account
Another way to build an application is to use pywebview's provided JS API or
windows.expose and serve static files locally.
pywebview offers a simple built-in web server that is good enough for serving local files. To use a local web server, set url to a local file and start the application with
See an example serverless application (opens new window)
- No external dependencies
- More straightforward architecture
- No risk of CSRF attacks
- Debugging has to be done inside the application using provided debugging tools
- EdgeHTML cannot serve local files.