Ask Documentation
WebsiteGitHubPyPI
  • Introduction
  • Getting Started
    • Install & Get Started
    • Hello, World!
  • Routes & Requests
    • Routes
    • Defining Routes
    • Request Data
    • HTTP Status Codes & Methods
    • CORS
  • Response
    • JSON Response
    • JSON Response With an HTTP Status Code
  • Classes
    • Class Instance Variable
    • Initialization/Constructor Method
  • Data Types
    • Dictionaries
  • Built-in Utilities
    • Quick_set()
    • Deep()
    • Serialize()
    • Require_keys()
    • Random Generators
    • Pattern Matching
    • Email
  • Database
    • Ask and Databases
    • Models/Classes
      • Columns
      • Initialization/Constructor
      • Serialization
      • The &basic decorator
    • CRUD
      • Add
      • Select
      • Update
      • Delete
    • Check if a Row Exists
    • Sorting
    • Database Lists
  • JWT Authentication
    • Introduction
    • Protecting Routes
    • How to Create a Basic Login System
    • Properties & Methods of _auth
    • Making Requests to Protected Routes
  • Decorators
    • What are Decorators?
    • Create and Use Custom Decorators
    • Built-in Decorators
  • Security
    • Hashing
    • Route Security
    • Environment Variables
  • Configuring the Transpiler
  • Askfile.toml
  • Modules & Libraries
    • Importing an Ask Module
    • Includes
    • Importing Python Modules
  • Development Tools
    • Editor Syntax Highlighting
    • Automatic API documentation
    • CLI Flags
    • Running in development mode
    • Versioning System
  • Contribute
    • Feature Requests
    • Bug Reports
    • Contribute Code
Powered by GitBook
On this page
  • Usage
  • Example
  • Include module paths
  • File structure
  • Pointing to sub-folders
Export as PDF
  1. Modules & Libraries

Includes

Split your apps into multiple files that you can import/insert into one another.

Includes allows you to move parts of your application into separate files. Includes (like the name suggests) simply inserts code from other files into another. The place where you use the include keyword will be the location to which the code will be inserted to.

Usage

Any .ask file can be treated as an include. You don't need to add anything special into include modules. Simple insert their contents into another .ask file using the include keyword.

Example

main.ask

@get('/a/1'):
    respond('Hello from A1')
    
@get('/a/2'):
    respond('Hello from A2') 

 include module_b 

module_b.ask

@get('/b/1'):
    respond('Hello from B1')
    
@get('/b/2'):
    respond('Hello from B2')

(Result) (app.ask)

@get('/a/1'):
    respond('Hello from A1')
    
@get('/a/2'):
    respond('Hello from A2') 

@get('/b/1'):
    respond('Hello from B1')
    
@get('/b/2'):
    respond('Hello from B2')

Include module paths

You can put include modules in the same directory as you're importing them from. You can also put them in sub-folders, and point to their paths using dots (like slashes in normal file paths)

File structure

- main.ask
    - modules/
        - module_b.ask

Pointing to sub-folders

include modules.module_b
PreviousImporting an Ask ModuleNextImporting Python Modules

Last updated 3 years ago